StringExtensionsTryParseT(String, CultureInfo, T) Method
Tries to parse an object of type
T from a
string value. Firstly, it tries to parse the type natively.
If
T 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(String, CultureInfo) method for details.
Namespace: KGySoft.CoreLibrariesAssembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 8.0.0
public static bool TryParse<T>(
this string? s,
CultureInfo? culture,
out T? value
)
<ExtensionAttribute>
Public Shared Function TryParse(Of T) (
s As String,
culture As CultureInfo,
<OutAttribute> ByRef value As T
) As Boolean
public:
[ExtensionAttribute]
generic<typename T>
static bool TryParse(
String^ s,
CultureInfo^ culture,
[OutAttribute] T% value
)
[<ExtensionAttribute>]
static member TryParse :
s : string *
culture : CultureInfo *
value : 'T byref -> bool
- s String
- The string value to parse. If and T is a reference or nullable type, then value will be .
- culture CultureInfo
- The culture to use for the parsing. If , then the InvariantCulture will be used.
- value T
- When this method returns with result, then this parameter contains the result of the parsing.
It can be even if s is and T is a reference or nullable type.
- T
- The desired type of the returned value.
Boolean, if
s could be parsed as
T, which is returned in the
value parameter; otherwise,
.In Visual Basic and C#, you can call this method as an instance method on any object of type
String. 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).