CInt


Definition: Returns an expression that has been converted to a Variantof subtype Integer.

 

Need to convert a value to the integer data type? No problem: not only will Windows PowerShell make the conversion for you, but it will also round the value off to the nearest whole number. (Some languages convert a value to an integer simply by stripping off the decimal point.) The following two commands assign a string value to the variable $a, then convert the data type of $ a tointeger:

 

$a = "11.57"
$a = [ int] $a

 

When you run these two commands and then echo back the value of $ a youshould get the following:

 

12

 

And if you run the GetType () method against $a you’ll see it now has the following data type:

 

IsPublic IsSerialName
-------- -------- ----
True     True     Int32