Just for fun, i'm trying to mimic a Pascal like function readLn(vars[]) that can take as many variables as arguments as you wish and take their values from Console input.
Like this:
int num1, num2;
string str1, str2;
readLn(num1, num2, str1, str2)
So far i have drafted the function as this:
private static void readLn(params Object[] args)
{
foreach (Object i in args)
{
string vartype = i.GetType().ToString();
// Being i the variable it should get its value from
// (vartype).Parse(Console.ReadLine());
// Something like that :P
}
}
Yes, not much at all. But since params won't accept being ref types i don't know how to modify original variables values (num1, num2, str1, str2, etc).
Any ideas?