Stylecop - determine if Double or Float

I use Stylecop to create some custom rules, and I'm trying to determine if I have a double or a floating one.

I can go through the instructions and get the CSTokenType. CSTokenType is a number and can be considered a string. But since this is just a number, I have no real way to find out if it has an int, float, long, double or something else.

How can I check what a primitive type is?

+3
source share
1 answer

EDIT

To determine if a numeric literal is double or floating, you should check if there is, and if so, which suffix is ​​present in CsToken.Text (when CsTokenType == CsTokenType.Number).

:

  • 15 -
  • 0.15 -
  • 0.15d -
  • 0.15f - float
  • 0.15m

: http://msdn.microsoft.com/en-us/library/aa691085(v=VS.71).aspx http://msdn.microsoft.com/en-us/library/aa664674(v=VS.71).aspx

+2

Source: https://habr.com/ru/post/1738526/


All Articles