Hi All,
I have a class that has a property returning IList. For example,
class A
{
public IList<stringMyList
{
get { return _list; }
set { _list = new List<string>(value); }
}
private List<string_list;
}
Now, I have a method that has an IEnumerable and tries to set MyList
property of an object of type A. Here is how I have done it:
void f(A a, IEnumerable<stringlist)
{
a.MyList = new List<string>(list);
}
The above works fine, but I think there must be a better way to
achieving this rather than create temporary List<stringobjects. This
happens twice - 1) While converting from IEnumerable<to IList<>, and
2) While converting from IList<to List<Last thing I would want is
to change the return type of the property or the signature of f(). Any
suggestions?
On side notes, how bad is it performance wise?
- Satyajit