I have code similar to the following in many places:
var dbParams = db.ReadParams(memberID, product, GetSubscriptionFields()); Debug.Assert(dbParams.Count == 4); _memberCode = dbParams[0]; _password = dbParams[1]; _userName = dbParams[2]; _reasonCode = dbParams[3];
ReadParams() returns an array of strings, the number of strings depending on the GetSubscriptionFields() function. I could use dbParams[] directly in my code, but I find it more helpful to give meaningful names to each of the values in the array. Is there a way I can get all the results directly, without going through the array?
I am looking for something like:
db.ReadParams(memberID, product, out _memberCode, out _password, out _userName, out _reasonCode);
or
Tuple<_memberCode, _password, _userName, _reasonCode> = db.ReadParams(memberID, product);
Of course, it has to be legal C# code 🙂
Why not use constants instead?
Then in your code you could have
which meets your goal of meaningful names without changing the way the method works.