dhivya N

dhivya N

  • NA
  • 2
  • 543

Generic Arrays- how to get data from user

Dec 8 2017 12:27 AM
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)