Reputation: 45
I created my class with a couple of properties.
And i was trying to use the List and create a constructor to send an object and have it creating the list with all the objects.
public class List<MyObject>
{
public List<MyObject>(object x)
{
//Do Things here
}
}
Is this possible?
Upvotes: 0
Views: 182
Reputation: 1085
Why do this ?
If you're looking for a means to create a list based on some domain requirements, I would look at Factorial patterns.
Upvotes: 0
Reputation: 3834
public class MyObject : List<IListType>
{
public MyObject(object x)
{
//Do Things here
}
}
Upvotes: 0
Reputation: 48
Would not be better to inherit List<>
for example :
class InheritClass : List<ITest>
{
public InheritClass(object parameter)
{
// do something
}
}
class test
{
public test()
{
InheritClass a = new InheritClass(new object());
a.Add(new ITest);
}
}
Upvotes: 3