I am new to inherit from list concept and I have a little confusion of initializing that.
Here is a simple example of my real code, here is my class that inherits from list:
public class List_Of_Int : List<int>
{
public string key{get; set;}
public List_Of_Int(string key)
{
this.key = key;
}
}
and here is where I need to initialize my variable:
List<int> list_of_int = new List<int>() { 1, 2, 3 };
List_Of_Int list_of_list = new List_Of_Int("some_key") **Some Code**
I want to assign list_of_int
to my list_of_list
, I believe there's a code replace some code that will do that, Is it true?
I know I can add by using AddRange(list_of_int )
later but I'm just wondering if I can do it while declaration?