I'm looking at inherited code and I found this in a vb.net windows form:
New System.Drawing.SizeF(6.0!, 13.0!)
My question is, what is the significance of the !
(exclamation) operator here? Most of my searching for the exclamation operator ends up returning recordset format or the !
gets ignored in the search and I get hundreds of unrelated items.
It's to force the literal to be a Single.
Visual Basic supports Type Characters:
In addition to specifying a data type in a declaration statement, you can force the data type of some programming elements with a type character. The type character must immediately follow the element, with no intervening characters of any kind.
and:
Literals can also use the identifier type characters (%, &, @, !, #, $), as can variables, constants, and expressions. However, the literal type characters (S, I, L, D, F, R, C) can be used only with literals.
In this case, the !
stands for Single
:
Type Characters. Appending the literal type character F to a literal forces it to the Single data type. Appending the identifier type character ! to any identifier forces it to Single.
(emphasis mine)
It is a type character. It means that 6.0 is a Single data type.
http://msdn.microsoft.com/en-us/library/s9cz43ek.aspx show the type characters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With