---
title: "generic list class in c#"  
description: "generic list class in c#"  
author: "Royce Roy"  
published: 2014-01-25  
updated: 2014-01-25  
canonical: https://www.mindstick.com/forum/1871/generic-list-class-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# generic list class in c#

I'm currently making my own very basic generic list class (to get a better [understanding](https://www.mindstick.com/articles/12918/cat-5e-vs-cat-6a-understanding-the-major-differences) on how the predefined ones work). Only [problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic) I have is that I can't reach the [elements](https://www.mindstick.com/forum/1440/wpf-button-with-multiple-text-elements) inside the [array](https://www.mindstick.com/articles/335/jagged-array-in-c-sharp-dot-net) as you normally do in say using "System.Collections.Generic.List".

GenericList<type> list = new GenericList<type>();

list.Add(whatever);

This [works fine](https://answers.mindstick.com/qa/115732/my-software-works-fine-on-windows-10-but-crashes-on-windows-11-why), but when [trying](https://answers.mindstick.com/qa/93698/6-mistakes-couples-are-trying-to-save-money) to [access](https://www.mindstick.com/articles/12994/how-foreigners-can-access-blocked-websites-in-china) "whatever" I want to be able to write :

list[0];

But that obviously doesn't work since I'm clearly [missing](https://answers.mindstick.com/qa/52138/international-missing-children-s-day-2019-was-observed-on) something in the code, what is it I need to add to my otherwise fully working [generic class](https://www.mindstick.com/forum/160399/how-to-create-a-custom-generic-class-in-c-sharp-provide-an-example) ?

## Replies

### Reply by Pravesh Singh

Hi Royce,

I think all you need to do is implement IList<T> , to get all the basic functionality

```
  public interface IList<T>   {    int IndexOf(T item);    void Insert(int index, T item);    void RemoveAt(int index);    T this[int index] { get; set; }  }
```


---

Original Source: https://www.mindstick.com/forum/1871/generic-list-class-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
