There is no argument given that corresponds to the required formal parameter - .NET Error

后端 未结 5 1095
迷失自我
迷失自我 2020-11-29 11:26

I have been re-factoring one of my old MSSQL Connection helper library and I got the following error:

Severity Code Description Project File Li

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-29 11:56

    I got this error when one of my properties that was required for the constructor was not public. Make sure all the parameters in the constructor go to properties that are public if this is the case:

    using statements namespace someNamespace

    public class ExampleClass {
    
      //Properties - one is not visible to the class calling the constructor
      public string Property1 { get; set; }
      string Property2 { get; set; }
    
       //Constructor
       public ExampleClass(string property1, string property2)
      {
         this.Property1 = property1;
         this.Property2 = property2;  //this caused that error for me
      }
    }
    

提交回复
热议问题