(object) is a 'field' but is used like a 'type'

后端 未结 3 1550
孤独总比滥情好
孤独总比滥情好 2020-12-02 01:52

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?

相关标签:
3条回答
  • 2020-12-02 02:27

    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.

    0 讨论(0)
  • 2020-12-02 02:28

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

    0 讨论(0)
  • 2020-12-02 02:47

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

    ChaosSoftware.WorldTime.LoadData("blahblah...");
    
    0 讨论(0)
提交回复
热议问题