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.
Answer
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.
Attribution
Source : Link , Question Author : Kakoroat , Answer Author : Damien_The_Unbeliever