I'm sure there was a way to easily instantiate the class, but my search in large interdeclarations did not find it. Let's say I have this:
List<LicencedCustomer> leftList = new List<LicencedCustomer>();
leftList.Add(new LicencedCustomer (LMAA_CODE:"1",LICENSE_NUMBER:"1",TRADING_NAME:"Bobs Liquor",STATE:"NSW",POSTCODE:"2261"));
My class is as follows.
public class LicencedCustomer
{
public string LMAA_CODE {get; set;}
public string LICENSE_NUMBER {get; set;}
public string TRADING_NAME {get; set;}
public string STATE {get; set;}
public string POSTCODE {get; set;}
public LicencedCustomer(string LMAA_CODE, string LICENSE_NUMBER, string TRADING_NAME, string STATE, string POSTCODE)
{
this.LMAA_CODE = LMAA_CODE;
this.LICENSE_NUMBER = LICENSE_NUMBER;
this.TRADING_NAME = TRADING_NAME;
this.STATE = STATE;
this.POSTCODE = POSTCODE;
}
...
Without a constructor right away, I get an error that the class does not contain a constructor that takes 5 arguments (initially I tried it only with the values and field names in the List.Add function).
Is there a shortcut that allows you to assign properties when creating without having to explicitly define the constructor?
Thank!
EDITING. Large-scale curiosity was caused by capitalized properties - they are there only because they were created to reflect the headers of the import file. Not my preferred method!