I have the following code that produces a compilation issue in my C# generic function:
static void solve () {
int[] vals = RA<int>();
}
and my RA function:
static T[] RA<T> () {
return Console.ReadLine ().Split ().Select (v => T.Parse (v)).ToArray ();
}
Giving me the following error:
Espression denotes a 'type parameter',
where a 'variable', 'value' or 'type' was expected
Can the community assist me in debugging or understanding this issue and resolving it?
The compiler don’t know a result type in compilation time and can’t link Parse call.
You should use Convert class to avoid compilation issue and limit generic type attribute