C# syntax to initialize custom class/objects through constructor params in array?
问题 I have a class with minimum 4 variables and I have made a constructor for the class so that I can initialize it with MyClass testobj = new MyClass(1234,56789,"test text", "something else", "foo"); Works fine. Then I have an array of these, that I need to parse in a loop, so I would like to get some static data into this array. My approach was: MyClass[] testobjlist = new MyClass { new MyClass(1001,1234,"Text 1", "abcdefghijklm", "ding"), new MyClass(1002,2345,"Text xx", "bla bla", "dong"),