how to adjust “is a type but is used like a variable”?

后端 未结 4 916
有刺的猬
有刺的猬 2020-12-06 11:07

I\'m trying to generate some code in a web service. But it\'s returning 2 errors:

1) List is a type but is used like a variable

2) No overload for method \

4条回答
  •  独厮守ぢ
    2020-12-06 11:37

    The problem is at the line

    List li = List();
    

    you need to add "new"

    List li = new List();
    

    Additionally for the next line should be:

    li.Add(new Customer{Name="yusuf", SurName="karatoprak", Number="123456"});
    

    EDIT: If you are using VS2005, then you have to create a new constructor that takes the 3 parameters.

    public Customer(string name, string surname, string number)
    {
         this.name = name;
         this.surname = surname;
         this.number = number;
    }
    

提交回复
热议问题