So I have a custom class (ie, MyClass), which I then use to declare an array. How would I add a ‘.Count’ property to my custom class to get the size of the array?
Thank you.
static void Main()
{
MyClass[] test = new MyClass[2];
test[0].str = "Hello";
test[1].str = "World";
Console.WriteLine("Count : " + test.Count);
}
class MyClass
{
public string str;
}
You have made an array, so it should already have a test.Length property.