C# Compiler : cannot access static method in a non-static context

前端 未结 5 652
独厮守ぢ
独厮守ぢ 2020-12-18 17:48

I have the code below :

public class Anything
{
    public int Data { get; set;}
}

public class MyGenericBase
{
    public void InstanceMethod(T da         


        
5条回答
  •  伪装坚强ぢ
    2020-12-18 18:19

    To call the static method you need to refer to it from the class it's defined in, not an instance of that class.

     MyGenericBase.StaticMethod( null );
    

提交回复
热议问题