[nfbcs] help with trivia game in C#

Drenth, Joe Joe.Drenth at JBTC.COM
Wed Apr 12 13:23:31 UTC 2017


Hi Jessica,

Error CS0120 means that you are calling a function of a class as if it were a static member function (perhaps calling it using the class name on the left of the period), but the function is not static, so you need to have an object instantiation on the left of the period. 

For example, the function "Is Null or Empty" is a static member of the String class, so it is called like this:

 If (String.IsNullOrEmpty (myString))
{ ... }

You can tell it is static by looking at the Syntax description of it on the MSDN page, which shows:

public static bool IsNullOrEmpty (string value)

On the other hand, the String function "Contains" is not a static function, so it is called like this:

If (myString.Contains ("abc"))
{ ... }

The Syntax of this function is as follows, which does not contain the keyword "static":
public bool Contains (string value)

If you send the code which is generating the error, I could help point out the proper way to call the specific function.

I can help you with arrays and making a database for your trivia app if you like. You can contact me off-list at:
Joe.drenth at jbtc.com

Hope this helps.

Joseph Drenth 
R&D Software Engineer 
JBT Corporation  |  Automated Systems 
400 Highpoint Drive 
Chalfont, PA  18914, USA
E: joe.drenth at jbtc.com  P: 215 822 4457
www.jbtc-agv.com 

-----Original Message-----
From: nfbcs [mailto:nfbcs-bounces at nfbnet.org] On Behalf Of Jessica Dail via nfbcs
Sent: Tuesday, April 11, 2017 6:12 PM
To: Andy B. via nfbcs
Cc: Jessica Dail
Subject: [nfbcs] help with trivia game in C#

Hi,
I’m trying to create a trivia game in C#.

I need help making arrays, and a database for the questions.

Does anyone have any suggestions on how I can accomplish this?

Also, I have an error. It’s CS0120. Can anyone tell me what it means, and how to fix it?
The description that MSDN provides, is written in suchv a way that it’s hard for me to understand.

Thanks,
Jessica


Sent from Mail for Windows 10

_______________________________________________
nfbcs mailing list
nfbcs at nfbnet.org
http://nfbnet.org/mailman/listinfo/nfbcs_nfbnet.org
To unsubscribe, change your list options or get your account info for nfbcs:
http://nfbnet.org/mailman/options/nfbcs_nfbnet.org/joe.drenth%40jbtc.com


More information about the NFBCS mailing list