Calling a Static method in C#

前端 未结 5 1499
[愿得一人]
[愿得一人] 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

    Static classes are generally used when you want to provide some utilities, so you do not have to create objects of those classes. You can call those methods from other classes by simply calling by class name and invoking the member function.

    For example here you can call as LocationTools.GetLocationFromIP();

    Hope it helps!

提交回复
热议问题