Why does the MinValue for an Int32 struct in C# ha

2020-04-03 02:16发布

问题:

When I right-click int in my code and select "Go To Definition," Visual Studio opens a file titled "Int32 [from metadata]". This file includes the following line:

public const Int32 MinValue = --2147483648;

What is the meaning of the double -- sign?


I am running Visual Studio 15.8.4. Based on information in the comments, this is not reproducible on all versions of Visual Studio 2017.

回答1:

vcsjones pointed to the newly created bug report and this post appeared there:

CyrusNajmabadi commented

This is probably a bug i introduced when i fixed up how literals were converted to syntax nodes. There was probably some special casing here that added a - sign. And once the underlying helper was fixed we got double negation.