简体   繁体   English

C#-类struct或接口成员声明中的无效令牌''

[英]C# - invalid token '' in class struct or interface member declaration

I've checked all the other questions asked here about the "Invalid Token ' ' in..." here, but none have been able to apply to my issue. 我已经检查了所有其他有关此处的“无效令牌''in ...”的问题,但没有一个能够解决我的问题。 And yes, the error list gave me an empty single quote to specify the invalid token. 是的,错误列表给了我一个空的单引号,以指定无效的令牌。 Below is my code (the namespace is not the actual one I'm using fyi): 下面是我的代码(名称空间不是我使用的fyi的实际名称):

namespace Testing.SeleniumUITests.PageObjects
  {


      public abstract class PageObject
      {
         public void TakeScreenshot(string filename)
         {
            try
            {
            Screenshot ss = ((ITakesScreenshot)webDriver).GetScreenshot();
            ss.SaveAsFile(@"C:\Screenshots\" + filename + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
            //var i2 = new Bitmap(ss);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw;
            }
        }
   ​ }
}

I'm not sure what is wrong with the method. 我不确定该方法有什么问题。 Am I missing a certain reference or any other 'using' namespaces? 我是否缺少某些参考或任何其他“使用”名称空间?

So it looks like there was a hidden character. 因此,看起来好像有一个隐藏的角色。 I received the code from a co-worker of mine thru messaging website and I guess that site just added that extra hidden character. 我从我的消息传递网站的同事那里收到了代码,我想该网站只是添加了额外的隐藏字符。

If anyone has this issue in the future where you have an empty invalid token error message, copy and paste the suspect code block into notepad and save it. 如果将来任何人遇到此问题,并且您收到一个无效的无效令牌错误消息,请将可疑代码块复制并粘贴到记事本中并保存。 Open it again and you should see the hidden character you couldn't see before. 再次打开它,您应该看到以前看不到的隐藏字符。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 类,结构或接口成员声明c#中的无效令牌'=' - Invalid token '=' in class, struct, or interface member declaration c# C#中的类结构或接口成员声明中的无效令牌 - Invalid token in class struct or interface member declaration in c# 令牌无效 ';' 在类,结构或接口成员声明中 - Invalid token ';' in class, struct, or interface member declaration 令牌无效 ';' 在类struct或接口成员声明中 - invalid token ';' in class struct or interface member declaration 类,结构或接口成员声明中的令牌'='无效 - Invalid Token '=' in class,struct or interface member declaration 类、结构或接口成员声明中的无效标记 - Invalid token in class, struct, or interface member declaration 类、结构或接口成员声明中的无效标记“}” - Invalid token '}' in class, struct, or interface member declaration 类、结构或接口成员声明中的无效标记“)”和“{” - Invalid token ')' and '{' in class, struct, or interface member declaration C#中的Lambda属性-“类,结构或接口成员声明中的无效令牌” - Lambda properties in C# - “Invalid token in class, struct, or interface member declaration” 类,结构或接口成员声明中的标记'='无效,类,结构或接口成员声明中的无效标记'(' - Invalid token '=' in class, struct, or interface member declaration, Invalid token '(' in class, struct, or interface member declaration
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM