I am trying to add an implicit conversion to my ViewModel class (VMSalesRep):
public static implicit operator IEnumerable<VMSalesRep> (IEnumerable<QuoteSalesRep> vm)
IEnumerable<VMSalesRep> result = vm.Select(x => new VMSalesRep()
QuoteSalesRepID = x.QuoteSalesRepID,
FirstName = x.FirstName,
LastName = x.LastName,
CommisionPercentage = x.CommisionPercentage
User-defined conversion must convert to or from the enclosing type
You can only declare implicit conversions from inside the class that you are coming from or going to. Because of that you would need to put the conversion inside the definition of
IEnumerable<T> because that is the type of both your source and destination, which can not be done.
You will not be able to do a implicit conversion from one IEnumerable to another.