1 ' Licensed to the .NET Foundation under one or more agreements.
2 ' The .NET Foundation licenses this file to you under the MIT license.
3 ' See the LICENSE file in the project root for more information.
6 Imports Microsoft.VisualBasic.CompilerServices.Utils
8 Namespace Microsoft.VisualBasic.CompilerServices
10 <System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)>
11 Public NotInheritable Class CharArrayType
16 Public Shared Function FromString(ByVal Value As String) As Char()
18 If Value Is Nothing Then
22 Return Value.ToCharArray()
26 Public Shared Function FromObject(ByVal Value As Object) As Char()
28 If Value Is Nothing Then
29 Return "".ToCharArray()
32 Dim CharArray As Char() = TryCast(Value, Char())
34 If CharArray IsNot Nothing AndAlso CharArray.Rank = 1 Then
38 Dim ValueInterface As IConvertible
39 ValueInterface = TryCast(Value, IConvertible)
41 If Not ValueInterface Is Nothing Then
42 If (ValueInterface.GetTypeCode() = TypeCode.String) Then
43 Return ValueInterface.ToString(Nothing).ToCharArray()
49 Throw New InvalidCastException(SR.Format(SR.InvalidCast_FromTo, VBFriendlyName(Value), "Char()"))