Getting Started With PowerShell Convert String To Number

Asked By 0 points N/A Posted on -
qa-featured

Can I use Power Shell convert string to number? I am facing problems while converting a string to an integer. How can I convert a string value to the number using Power Shell Prompt? Give me an example to help me understand better.

SHARE
Answered By 0 points N/A #112408

Getting Started With PowerShell Convert String To Number

qa-featured

Let me explain this with an example, suppose you want to convert 2.3 to 23, try this simple method:

[string]$strNum = "2.3"

[int]$intNum = [convert]::ToInt32($strNum, 10)

$intNum

Here the string is first converted to the int32 and I have used the base number as 10 to convert decimal number into the binary one.

Login/Register to Answer

Related Questions