// struct is like Record in DELPHI
public struct CountryCode
{
public string Country;
public int Code;
public CountryCode(string ACountry, int ACode)
{
Country = ACountry;
Code = ACode;
}
}
// init and fill the array
static readonly CountryCode[] CountriesArray = new CountryCode[]
{
new CountryCode("USA", 1),
new CountryCode("CANADA", 1),
new CountryCode("EGYPT", 20),
new CountryCode("GREECE", 30),
new CountryCode("ITALY", 39)
};
// init List with a pre-existing array
static readonly List<CountryCode> CountriesList1 = new List<CountryCode>(CountriesArray);
// init List directly
static readonly List<CountryCode> CountriesList2 = new List<CountryCode>(
new CountryCode[]
{
new CountryCode("USA", 1),
new CountryCode("CANADA", 1),
new CountryCode("EGYPT", 20),
new CountryCode("GREECE", 30),
new CountryCode("ITALY", 39)
});
| Next > |
|---|





