(object) is a ‘field’ but is used like a ‘type’

My intellisense is giving me the error:
‘ClassLibrary1.GetTimeZone.myWorldTime’ is a ‘field’ but is used like a ‘type’

Any idea what I’m doing wrong?

My code

!Object Browser for the class1
My code

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

You need to put the line in error in a class constructor or a method.

Method 2

LoadData is a static method. You call it on the type, not an instance.

ChaosSoftware.WorldTime.LoadData("worldtime.xml");

This needs to be placed inside a method in order to execute (constructor or other method).

Additionally, though not the reason for the error, you should use " to delimit a string. In C#, single quotes are for character literals (that is, single characters). What you have will not compile.

Method 3

LoadData seems to be a static function, so you should do this instead (without an object instance):

ChaosSoftware.WorldTime.LoadData("blahblah...");


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x