Q
Q2004
What's the significant of private construtor ?
public class Car{
private string m_strName;
private string m_strType;
private int m_nID;
private Car(string name, string type, int ID)
{
m_strName = name;
m_strType = type;
m_nID = ID;
}
public static string Name
{
get
{
return m_strName;
}
}
}
I intended to create an enumeration class similar to Color
class in .NET framework.
Color mycolor = Color.Blue;
How should I modify the class above to make the following
works ?
Car car = car.NISSAN;
Thanks in advance.
public class Car{
private string m_strName;
private string m_strType;
private int m_nID;
private Car(string name, string type, int ID)
{
m_strName = name;
m_strType = type;
m_nID = ID;
}
public static string Name
{
get
{
return m_strName;
}
}
}
I intended to create an enumeration class similar to Color
class in .NET framework.
Color mycolor = Color.Blue;
How should I modify the class above to make the following
works ?
Car car = car.NISSAN;
Thanks in advance.