开发者

Using minus in C#

开发者 https://www.devze.com 2023-01-12 19:36 出处:网络
I want to use - in the code below but Visual Studio doesn\'t let me to use it and gives \"error, unexpected character\".

I want to use - in the code below but Visual Studio doesn't let me to use it and gives "error, unexpected character".

    Name = objFileInfo.Name.Substring(0,  
        objFileInfo.Name.Length – objFileInfo.Extension.L开发者_如何学Goength);  


It is not a minus you are using:

Yours (char 8211, a math minus):

Minus (shorter, char 45 ascii, a dash which represents minus in C#):

-

Try copy the c# minus I use above and it will work :-)


In C# (and I imagine almost any other programming language), the minus sign is simply represented by an ASCII dash, or hyphen-minus, which is a single keystroke on standard ASCII keyboards:

-

Not the mathematical minus symbol, which you're using:


That character... whatever character it is... is not a minus (ascii code 45).

0

精彩评论

暂无评论...
验证码 换一张
取 消