定義Dog類型時(shí)報(bào)錯(cuò)
? ? ? ? ? ? List<Dog> list = new List<Dog>();
? ? ? ? ? ? list.Add(new Dog("A"));
? ? ? ? ? ? list.Add(new Dog("B"));
? ? ? ? ? ? list.Add(new Dog("C"));
我在用list定義完之后 Dog 會(huì)報(bào)錯(cuò) 這樣怎么解決呢
? ? ? ? ? ? List<Dog> list = new List<Dog>();
? ? ? ? ? ? list.Add(new Dog("A"));
? ? ? ? ? ? list.Add(new Dog("B"));
? ? ? ? ? ? list.Add(new Dog("C"));
我在用list定義完之后 Dog 會(huì)報(bào)錯(cuò) 這樣怎么解決呢
2018-12-20
舉報(bào)
2019-02-28
是不是你的Dog類定義的有問(wèn)題啊
?public class Dog
? ? {
? ? ? ? private string name;
? ? ? ? public Dog(string name){
? ? ? ? ? ? this.name = name;
? ? ? ? }
? ? }
?List<Dog> list = new List<Dog>();
? ? ? ? ? ? list.Add(new Dog("A"));
? ? ? ? ? ? list.Add(new Dog("B"));
? ? ? ? ? ? list.Add(new Dog("C"));
2019-01-02
dog累設(shè)置有問(wèn)題吧