| Init an array |
|
|
|
|
ASPX.CS C# - How to init an array int[] values = new int[] { 0, 8000, 13800, 0, 0, 0, 0, 10300, 4700, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; MORE COMPLEX - How to init an array and a List (Collection in Delphi) public struct CountryCode { public string Country; public int Code; public CountryCode(string ACountry, int ACode) { Country = ACountry; Code = ACode; } } staticd 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) }); |
|
| Last Updated ( Thursday, 04 October 2007 ) |
| < Prev | Next > |
|---|




Articles 




