Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclamation(!) operator used on a number in vb.net, what does this do?

Tags:

vb.net

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.

like image 472
Kakoroat Avatar asked Jul 18 '11 12:07

Kakoroat


3 Answers

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.

like image 58
Damien_The_Unbeliever Avatar answered Oct 22 '22 11:10

Damien_The_Unbeliever


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)

like image 30
Oded Avatar answered Oct 22 '22 12:10

Oded


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.

like image 39
dbasnett Avatar answered Oct 22 '22 12:10

dbasnett