Cannot implicitly convert type ... to ... problem

Posted by Younes on Stack Overflow See other posts from Stack Overflow or by Younes
Published on 2010-04-22T13:14:11Z Indexed on 2010/04/22 13:23 UTC
Read the original article Hit count: 261

Filed under:
|
|

I have this code:

       public static IEnumerable<dcCustomer> searchCustomer(string Companyname)
    {
        TestdbDataContext db = new TestdbDataContext();


        IEnumerable<dcCustomer> myCustomerList = (from Customer res
                                                  in db.Customers
                                                  where res.CompanyName == Companyname
                                                  select res);

        return myCustomerList;



    }

And whatever i try i keep getting the convert error.

Error 1 Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<ConnectionWeb.Customer>' to 'System.Collections.Generic.IEnumerable<ConnectionWeb.DAL.dcCustomer>'. An explicit conversion exists (are you missing a cast?) \\srv01\home$\Z****\Visual Studio 2008\Projects\ConnectionWeb\ConnectionWeb\DAL\dcCustomer.cs 63 20 ConnectionWeb

I want to try get myCustomerList to keep the values in an enumerator and return it.

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET