deanlee17
asked on
Using Get Set
Hi guys,
I have the following class:
Then outside of that class:
Then later in the project....
This is to set a default, I know im doing it wrong/inefficiently, now I tried the following but it errors, so how do I set a default in this case?
I have the following class:
public class DropdownColumnNumberMatch
{
public string RFQ_Number { get; set; }
}
Then outside of that class:
private DropdownColumnNumberMatch Instance_DropdownColumnNumberMatch;
Then later in the project....
Instance_DropdownColumnNumberMatch = new DropdownColumnNumberMatch();
Instance_DropdownColumnNumberMatch.RFQ_Number = "Unset";
This is to set a default, I know im doing it wrong/inefficiently, now I tried the following but it errors, so how do I set a default in this case?
public class DropdownColumnNumberMatch
{
public string RFQ_Number { get { return RFQ_Number; } set { RFQ_Number = "Unset"; } }
}
Thanks,
Dean
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
yes exactly, constructor is one place to set default values to public properties.
FYI: This would actually result in an endless loop:
public string RFQ_Number { get { return RFQ_Number; } ...
ASKER
Thanks
ASKER
Open in new window