Create a generic class, madLabClass • The class will have 2 fields o One is an i
ID: 3859348 • Letter: C
Question
Create a generic class, madLabClass
• The class will have 2 fields o One is an integer for an index o The second is an array of the generic class type
• A constructor for the class will take in one parameter of int o This will create the array backing field to be of the size sent in o The index will be set to 0
• A function called GetValue o will print out the current value of the array being pointed at by the index o will advance the index by one o if the index is out of range, loop it back to the beginning
Need answer in C# windows form ASAP
Explanation / Answer
public class madLabClass<T>
{
private T[] array;
private int index;
public MyGenericArray(int size)
{
array = new T[size + 1];
index = 0;
}
public T getValue()
{
return array[index];
index++;
if (index == array.Length)
{
index = 0;
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.