Error - invalid token '(' in class struct or interface member declaration in c# -
my code -
public partial class app : application { harvestapp.googleapimanager gapimanager = new harvestapp.googleapimanager(); list<event>todaycalendar = gapimanager.getcalendareventsfordate(datetime.today); harvestapp.harvestmanager hapimanager = new harvestapp.harvestmanager(); console.writeline("entries found today :" + todaycalendar.count); foreach(event todayevent in todaycalendar) { var addevent = new harvestapp.harvest_timesheetentry(todayevent); entrylist.add(addevent); hapimanager.postharvestentry(addevent); } }
it gives me token error. please help.
the problem did put code directly in class , not inside member constructor:
public partial class app : application { public app() { harvestapp.googleapimanager gapimanager = new harvestapp.googleapimanager(); list<event>todaycalendar = gapimanager.getcalendareventsfordate(datetime.today); harvestapp.harvestmanager hapimanager = new harvestapp.harvestmanager(); console.writeline("entries found today :" + todaycalendar.count); foreach(event todayevent in todaycalendar) { var addevent = new harvestapp.harvest_timesheetentry(todayevent); entrylist.add(addevent); hapimanager.postharvestentry(addevent); } } }
Comments
Post a Comment