C# 错误-无效令牌';(';在c中的类结构或接口成员声明中)#
我的密码是-C# 错误-无效令牌';(';在c中的类结构或接口成员声明中)#,c#,invalid-characters,C#,Invalid Characters,我的密码是- public partial class App : Application { HarvestApp.GoogleAPIManager GAPImanager = new HarvestApp.GoogleAPIManager(); List<Event>todayCalendar = GAPImanager.GetCalendarEventsForDate(DateTime.Today); HarvestApp.HarvestManag
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 for Today :" + todayCalendar.Count);
foreach(Event todayEvent in todayCalendar)
{
var addEvent = new HarvestApp.Harvest_TimeSheetEntry(todayEvent);
EntryList.Add(addEvent);
HAPIManager.postHarvestEntry(addEvent);
}
}
公共部分类应用程序:应用程序
{
HarvestApp.GoogleAppManager GAPImanager=新的HarvestApp.GoogleAppManager();
ListtodayCalendar=GAPImanager.GetCalendarEventsForDate(DateTime.Today);
HarvestApp.HarvestManager HAPIManager=新的HarvestApp.HarvestManager();
Console.WriteLine(“找到今天的条目:+todayCalendar.Count”);
foreach(今天日历中的事件todayEvent)
{
var addEvent=新的HarvestApp.Harvestu时间表(todayEvent);
EntryList.Add(addEvent);
HAPIManager.postHarvestEntry(addEvent);
}
}
它给了我令牌错误。请帮助。问题是您确实将代码直接放在类中,而不是像构造函数一样放在成员中:
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 for Today :" + todayCalendar.Count);
foreach(Event todayEvent in todayCalendar)
{
var addEvent = new HarvestApp.Harvest_TimeSheetEntry(todayEvent);
EntryList.Add(addEvent);
HAPIManager.postHarvestEntry(addEvent);
}
}
}
公共部分类应用程序:应用程序
{
公共应用程序()
{
HarvestApp.GoogleAppManager GAPImanager=新的HarvestApp.GoogleAppManager();
ListtodayCalendar=GAPImanager.GetCalendarEventsForDate(DateTime.Today);
HarvestApp.HarvestManager HAPIManager=新的HarvestApp.HarvestManager();
Console.WriteLine(“找到今天的条目:+todayCalendar.Count”);
foreach(今天日历中的事件todayEvent)
{
var addEvent=新的HarvestApp.Harvestu时间表(todayEvent);
EntryList.Add(addEvent);
HAPIManager.postHarvestEntry(addEvent);
}
}
}
您不能声明如下代码指令:
Console.WriteLine("Entries found for Today :" + todayCalendar.Count);
foreach(Event todayEvent in todayCalendar)
{
var addEvent = new HarvestApp.Harvest_TimeSheetEntry(todayEvent);
EntryList.Add(addEvent);
HAPIManager.postHarvestEntry(addEvent);
}
在你的班级里
您应该在构造函数或特定方法中进行这些调用。在哪一行出现错误?