Let's say I have an array of custom type, and I put in it 10 objects of custom struct type.
CustomType[] Record = new CustomType[10];
Now since each CustomType has fields, I can assign the fields for each element of CustomType in the array. For example:
Record[0].name = "John";
Record[0].age = 34;
And there is the ToString() method, which in usual types like int or string, turns the value of the type to string. So if we had
someIntArray[0] = 32;
Console.WriteLine(someIntArray[0].ToString());
Then we would get the output "32" on the console, not its value type, int.
But if we use the same method on the above example with the CustomType array, and write:
Console.WriteLine(Record[0].ToString());
Then we won't get the value(s) that the object contains (in its fields), but the type of it. Of course I could write for example:
Console.WriteLine(Record[0].name + Record[0].age);
But you can see how if the struct has many fields this gets old and tedious very fast. And especially if you don't want to just print out all the fields of just one struct object, but all of the struct objects in the array.
So here is my question: Is there a method in .NET, or some other easy way so I can manipulate (e.g. print) all the fields of an array element like a struct in a simpler, faster way ?