Click here to Skip to main content
15,890,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
public List<BOL.MonthlyEvent> List(string subsidiary_cd,string costcenter)
{
    oConnection.ConnectionString = ConnectionString;
    oConnection.Open();
    BOL.MonthlyEvent MEvent = new BOL.MonthlyEvent();
    SqlCommand oCommand = new SqlCommand();
    oCommand.Connection = oConnection;
    oCommand.CommandType = CommandType.StoredProcedure;
    oCommand.CommandText = "Monthly_Event_LIST1";
    oCommand.Parameters.Add(new SqlParameter("@SUBS_CD", subsidiary_cd));
    oCommand.Parameters.Add(new SqlParameter("@CostCenter", costcenter));
    SqlDataReader oReader = oCommand.ExecuteReader();
    while (oReader.Read())
    {

        if (oReader["Event_Date"].ToString() == "") { Event.EventDate = null; } else { MEvent.EventDate = Convert.ToDateTime(oReader["Event_Date"].ToString()); }
        MEvent.EventTitle = oReader.IsDBNull(oReader.GetOrdinal("EventTitle")) ? "" : oReader["EventTitle"].ToString();
        MEvent.EventDescription = oReader.IsDBNull(oReader.GetOrdinal("Event_Description")) ? "" : oReader["Event_Description"].ToString();
    }
    oReader.Close();
    oConnection.Close();
    return MEvent;
}


error :
C#
cannot implicitly convert type'BOL.MonthlyEvent' to 'system.collections.generic.list<BOL.MonthlyEvent>'


What I have tried:

cannot implicitly convert type to system.collections.generic.list
Posted
Updated 26-Jun-16 17:16pm

1 solution

Your Method name is "List" which conflict with "System.Collections.Generic.List".
Solution is:-
Change the method name List to any thing which doesn't refer to Predefined keyword or class name....
 
Share this answer
 
v2
Comments
Karthik_Mahalingam 27-Jun-16 2:19am    
5
JayantaChatterjee 27-Jun-16 2:24am    
thank You....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900