Hi,
shapper wrote:
Hello,
I need to pass to a function a list of pairs of values.
For each item the first value is a string and the second value is an
Enum named Country.
For example, consider I need to pass 3 items:
"New York", Country.UnitedStates
"Paris", Country.France
"London", Country.England
What data type should I use create this?
And how can I access each item inside my function?
Thanks,
Miguel
You could use a struct for this. Something like
public struct CityInfo
{
string name;
Country countryCode;
}
and then
CityInfo ny = new CityInfo();
ny.name = "New York";
ny.countryCode = Country.UnitedStates;
Structs are good when you need lightweight objects, like here for
logical grouping of attributes. Note however that contrarily to classes,
structs are value types, not reference types.
HTH,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog:
http://www.galasoft-LB.ch
PhotoAlbum:
http://www.galasoft-LB.ch/pictures
Support children in Calcutta:
http://www.calcutta-espoir.ch