Convert.ToChar(String,IFormatProvider) converts the first character of string to a Unicode character with culture format
Imports System.Globalization
Public Class DummyProvider
Implements IFormatProvider
Public Function GetFormat( argType As Type ) As Object Implements IFormatProvider.GetFormat
Dim argStr As String = argType.ToString( )
If argStr = "" Then argStr = "Empty"
argStr = argStr.Substring( argStr.LastIndexOf( "."c ) + 1 )
Console.Write( "{0,-20}", argStr )
Return Nothing
End Function
End Class
Module ConvertNonNumericProviderDemo
Sub Main( )
' Create an instance of IFormatProvider.
Dim provider As New DummyProvider( )
' Convert these values using DummyProvider.
Dim Int32A As String = "-2"
Console.WriteLine( Convert.ToInt32( Int32A, provider ) )
End Sub
End Module
Related examples in the same category