473,405 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Data type. Multi pair of values. How can I do this?

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

Feb 24 '07 #1
2 983
"shapper" <md*****@gmail.comwrote in message
news:11**********************@j27g2000cwj.googlegr oups.com...
What data type should I use create this?

And how can I access each item inside my function?
http://msdn2.microsoft.com/en-us/library/xfhwa508.aspx
Feb 24 '07 #2
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
Feb 24 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Nicolas Keller | last post by:
Hi! I'm used to have Mozilla for testing my PHP sites when I'm coding. The site's nearly finished, now I've made a test with the Internet Exlporer... guess what... failed. The problem: I'm...
5
by: Leif K-Brooks | last post by:
I'm writing a relatively simple multi-user public Web application with Python. It's a rewrite of a similar application which used PHP+MySQL (not particularly clean code, either). My opinions on...
0
by: Eric | last post by:
I've got a weird problem, regardless of how often I enter: perl -MCPAN -e 'install "Data::Dumper"' I never get a message telling me that it is up-to-date. It will always try to reinstall even...
1
by: sqlvs | last post by:
Good citizens of Gotham, I'm encountering an odd problem when comparing two values converted to type double, as follows (please pardon the per-line script blocks): <%="|" &...
3
by: John Dunlop | last post by:
(Note crosspost and follow-ups to ciwah.) Nicolas Keller wrote in thread "Differences in form handling btw Mozilla and IE?": > The problem: I'm using a form that submit's (POST) its data via...
10
by: Zap | last post by:
Widespread opinion is that public data members are evil, because if you have to change the way the data is stored in your class you have to break the code accessing it, etc. After reading this...
5
by: Michael Hill | last post by:
Hi, folks. I am writing a Javascript program that accepts (x, y) data pairs from a text box and then analyzes that data in various ways. This is my first time using text area boxes; in the past,...
5
by: Robert Oschler | last post by:
I am converting a Perl script over to "C" for a potential open source project. I need some open source "C" code that will give me the same functionality of a Perl Style associative array: ...
1
by: Greg Buchholz | last post by:
/* The program below causes my compiler to run out of memory. I thought I'd run it past c.l.c++ to see if I made any obvious errors, or, if this behavior was to be expected. I'm guessing the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.