I got a function which wants to send 2 INT parameters back to where it has been called, but not sure what would be the best option, a Dictionary ? or a List or an Array
EDITED
I am using .Net framework 2
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I assume you mean return 2 values to the caller. If so:
Tuple<T1, T2>MyOperationResultoutparameters: http://msdn.microsoft.com/en-us/library/t3c3bfhx(v=vs.80).aspxIt depends on what is easiest for the caller to understand, i.e. what best demonstrates your intention?
Returning a variable-size collection may not be intuitive if the result will always have two values. My preference is either a Tuple or a custom type. A Tuple has the advantage of being an existing type, but the disadvantage that it’s not clear what its members mean; they are just called “Item1”, “Item2”, and so on.
The
outkeyword is nice for operations which may not succeed and always return a bool, likepublic bool int.TryParse( string value, out int parsedValue ). Here the intent is clear.