1
Answer

Generic Arrays- how to get data from user

dhivya N

dhivya N

7y
150
1
How to take input from user for generic arrays? 
class MyGenericArray<T>
{
T[] arr;
public MyGenericArray(int size)
{
T[] arr = new T[(size)];
Console.WriteLine("Pls enter {0} no of values", size);
for (int i = 0; i < size; i++)
{
arr[i] = Console.ReadLine() < T >; //am getting error here when i use convert.toint32(console.readline();-error states that generic cannot be converted to int.
}
}
 
Answers (1)