M
M Shafaat
Hi!
I want to write a method for assigning values to a group of variables in an
iteration, something like the following code:
public static void AssignValsToVars (string [] MyValues, ref params int []
MyVariables)
// The MyValues and MyVariables must have the same length.
{
for (i = 0; i < MyValues.Length; i++)
{
MyVariables = MyValues;
}
}
The code as above gives an exception sayiong that params and ref attibutes
are not allowed to use together.
The reason for I want to do this in this way is that among other advantages,
the amount of code will be short, regardless of how many variables you want
to assign.
Do you know a way to achieve this which is allowed?
Regards
M Shafaat
I want to write a method for assigning values to a group of variables in an
iteration, something like the following code:
public static void AssignValsToVars (string [] MyValues, ref params int []
MyVariables)
// The MyValues and MyVariables must have the same length.
{
for (i = 0; i < MyValues.Length; i++)
{
MyVariables = MyValues;
}
}
The code as above gives an exception sayiong that params and ref attibutes
are not allowed to use together.
The reason for I want to do this in this way is that among other advantages,
the amount of code will be short, regardless of how many variables you want
to assign.
Do you know a way to achieve this which is allowed?
Regards
M Shafaat