Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclamation point (!) in VB.NET

Tags:

vb.net

The following code is designer generated:

Me.lblXRay.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))

What does 8.0! mean?

like image 801
BlueRaja - Danny Pflughoeft Avatar asked Oct 27 '10 19:10

BlueRaja - Danny Pflughoeft


1 Answers

This dates back to very early versions of Microsoft Basic. These type characters let you both set the type of an identifier and a literal:

    Dim singleVar! = 1.2!
    Dim doubleVar# = 1.2#
    Dim decimalVar@ = 1.2@
    Dim integerVar% = 12%
    Dim longVar& = 12&
    Dim stringVar$ = "12"

    Function ReturnsString$(ByVal takesLong&)
like image 180
Hans Passant Avatar answered Nov 16 '22 02:11

Hans Passant