I have this small class and have made an array, see code below.
class clsTest
{
UInt32 m_myType = 0;
UInt64 m_DBID = 0;
String m_MyDescription = "";
}
clsTest[] myTest = new clsTest[20];
I assume 20 will be enough but what if, when the application is running, it needs extra.
My Question: Is it possible to add extra element(s) dynamically by code so I can have 21 or more?
__________________________________
khao san road
C# Adding to an array of classes?
Moderator: moderators
Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.
Thank you for your support.
Re: C# Adding to an array of classes?
chanika wrote:I have this small class and have made an array, see code below.
class clsTest
{
UInt32 m_myType = 0;
UInt64 m_DBID = 0;
String m_MyDescription = "";
}
clsTest[] myTest = new clsTest[20];
I assume 20 will be enough but what if, when the application is running, it needs extra.
My Question: Is it possible to add extra element(s) dynamically by code so I can have 21 or more?
__________________________________
khao san road
You may be able to use a List or Dictionary to accomplish this rather than an array:
List<clsTest> myTest = new List<clsTest>();