SpanExtensionsParse(ReadOnlySpanChar, Type, CultureInfo) Method
Parses an object from a
ReadOnlySpan<char> value.
Firstly, it tries to parse the type natively. If
type cannot be parsed natively but the type has a
TypeConverter
or a registered conversion that can convert from string, then the type converter or conversion will be used.
See the
Remarks section of the
ParseT(ReadOnlySpanChar, CultureInfo) overload for details.
Namespace: KGySoft.CoreLibrariesAssembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 9.0.0-preview.1
public static Object? Parse(
this ReadOnlySpan<char> s,
Type type,
CultureInfo? culture = null
)
<ExtensionAttribute>
Public Shared Function Parse (
s As ReadOnlySpan(Of Char),
type As Type,
Optional culture As CultureInfo = Nothing
) As Object
public:
[ExtensionAttribute]
static Object^ Parse(
ReadOnlySpan<wchar_t> s,
Type^ type,
CultureInfo^ culture = nullptr
)
[<ExtensionAttribute>]
static member Parse :
s : ReadOnlySpan<char> *
type : Type *
?culture : CultureInfo
(* Defaults:
let _culture = defaultArg culture null
*)
-> Object
- s ReadOnlySpanChar
- The ReadOnlySpan<char> value to parse. If represents and type is a reference or nullable type, then the method returns .
- type Type
- The desired type of the return value.
- culture CultureInfo (Optional)
- The culture to use for the parsing. If , then the InvariantCulture will be used. This parameter is optional.
Default value: .
ObjectAn object of
type, which is the result of the parsing.In Visual Basic and C#, you can call this method as an instance method on any object of type
ReadOnlySpanChar. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).