CSng Function in VB.Net
What is CSng Function?
Explanation
CSng Function
CSng Function in Visual Basic.net 2008 is used to convert an expression to Single Datatype. This function uses the locale settings of the system to convert to single datatype.
Syntax:
CSng(expression)
Example:
Module Module1
Sub Main()
Dim a As Double = 23.568689
Console.WriteLine("Value of Double Expression converted to Single datatype is:: " & CSng(a))
Console.ReadLine()
End Sub
End Module
Result:
Value of Double Expression converted to Single datatype is:: 23.56869
In the above CSng Function example, a double value '23.568689' is converted to Single datatype to
return '23.56869'.