I have a list which is being populated from the database. The list is of this format:
class Event
{
public int EventID { get; set; }
public string EventName { get; set; }
public string EventManager { get; set; }
public int EventManagerID { get; set; }
public string EventTicketID { get; set; }
}
class Manager
{
public int ManagerID { get; set; }
public string ManagerName { get; set; }
public string ManagerShortName { get; set; }
public bool IsActive { get; set; }
}
The EventTicketID is usually populated by an integer. But at times, the ticketID also has strings in it. This happens when an Event Manager sub-contracts to another management company in which case the EventTicketId is populated with the format ManagerShortName_TicketID. I want to know check if an event is contracted to an event manager or is contracted to a sub-manager. So I want to check if the EventTickedId is an integer or has strings in it.
I tried checking by using:
//EventList being populated from db in an instance of List<Event> called listEvents
int directContractTicketID = Convert.ToInt32(listEvent[0].EventTicketID);
But I get Unhandled exception. can someone tell me how I can check if if EventTicketId is string or integer?