I'm relatively new to C#, so the concept of default values is somewhat confusing to me.
I currently have an object which contains two String values, serialNumber and fullPath. It's a simple object containing nothing but these two Strings and respective getter methods (they are not to be changed after Object creation; hence the absence of setter methods).
I want to put a List of these objects into a CheckedListBox. I want the box to display only the serial number and not the full path. According to MSDN, the CheckedListBox uses the default String value of the object. How can I set this to serialNumber when the object is created? Again, it should not be changed afterwards. Also, I'm not a big fan of the get and set keywords (I come from a Java background), so if if possible, I'd like to do this with more conventional getters/setters as I've done below for purposes of code readability.
class ModuleData
{
private String serialNumber;
private String fullPath;
public ModuleData(String serialNumber, String fullPath)
{
this.serialNumber = serialNumber;
this.fullPath = fullPath;
}
public String getSerialNumber()
{
return serialNumber;
}
public String getFullPath()
{
return fullPath;
}
public String toString()
{
return serialNumber;
}
public String DefaultValue
{
return serialNumber;
}
}
override