M
Mick
Hello, I know C++ but am new to C# so bear with me.
I want to create an array of my own class. Something like this:
///////////////////////////////////////
class CLoginInfo
{
public string name;
public string id;
public string pw;
public CLoginInfo()//constructor
{
this.name = "";//initialize
this.id = "";
this.pw = "";
}
}
private CLoginInfo[] m_logins;
public Form1()
{
m_logins = new CLoginInfo[3];
...
m_logins[0].name = "Mick";//???? exception!!!
m_logins[0].id = "MicksID";
m_logins[0].pw = "MicksPW";
...
m_logins[1].name = "Joe";
m_logins[1].id = "JoesID";
m_logins[1].pw = "JoesPW";
...
}
///////////////////////////////////////
This compiles but I get the runtime exception error: "Object reference
not set to an instance of an object."
What is the proper syntax?
Also is there a way to dynamically change the size of the array?
Thank you for any suggestions,
Mick
I want to create an array of my own class. Something like this:
///////////////////////////////////////
class CLoginInfo
{
public string name;
public string id;
public string pw;
public CLoginInfo()//constructor
{
this.name = "";//initialize
this.id = "";
this.pw = "";
}
}
private CLoginInfo[] m_logins;
public Form1()
{
m_logins = new CLoginInfo[3];
...
m_logins[0].name = "Mick";//???? exception!!!
m_logins[0].id = "MicksID";
m_logins[0].pw = "MicksPW";
...
m_logins[1].name = "Joe";
m_logins[1].id = "JoesID";
m_logins[1].pw = "JoesPW";
...
}
///////////////////////////////////////
This compiles but I get the runtime exception error: "Object reference
not set to an instance of an object."
What is the proper syntax?
Also is there a way to dynamically change the size of the array?
Thank you for any suggestions,
Mick