Par ma

Par ma

  • NA
  • 6
  • 789

Please rectify this C# error I tried using google also.

Nov 11 2017 4:46 AM
using System;
using System.Collections.Generic;
namespace GenericApplication
{
public class MyGenericApplication<T>
{
private T[] array;
public static MyGenericArray(int size)
{
return MyGenericArray[size];
}
public T getItem(int index)
{
return array[index];
}
public void setItem(int index,T value)
{
return array[index]=value;
}
}
class tester
{
public static void Main(string[]args)
{
MyGenericArray<int> intArray=new MyGenericArray<int>(5);
for (int c=0;c<5;c++)
{
intArray.setItem(c,c*5);
}
for (int c=0;c<5;c++)
{
Console.Write(intArray.getItem(c)+" ");
}
Console.WriteLine();
MyGenericArray<char> charArray=new MyGenericArray<char>(5);
for (int c=0;c<5;c++)
{
charArray.setItem(c,(char)(c+97));
}
for (int c=0;c<5;c++)
{
Console.Write(charArray.getItem(c)+" ");
}
Console.WriteLine();
}
}
}
main.cs(8,16): error CS1520: Class, struct, or interface method must have a return type



Answers (3)