Calling a Static method in C#

前端 未结 5 1514
[愿得一人]
[愿得一人] 2021-02-19 11:46

How do I call a static method? I want to call this from a class I have created, I want to get the location from IP. I\'ve declared it but what I need to do is call the method...

5条回答
  •  花落未央
    2021-02-19 12:09

    LocationTools.GetLocationFromIP( ... ) ;
    

    You should read up about Static Classes and Members on MSDN

    Static classes and class members are used to create data and functions that can be accessed without creating an instance of the class. Static class members can be used to separate data and behavior that is independent of any object identity: the data and functions do not change regardless of what happens to the object. Static classes can be used when there is no data or behavior in the class that depends on object identity.

提交回复
热议问题