StringSegmentExtensionsToEnumTEnum Method

KGy SOFT Core Libraries Help
Tries to convert the specified StringSegment to an Enum value of TEnum type. No string allocation occurs when using this method.

Namespace:  KGySoft.CoreLibraries
Assembly:  KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 6.0.0

public static TEnum? ToEnum<TEnum>(
	this StringSegment s,
	bool definedOnly = false
where TEnum : struct, new()


Type: KGySoft.CoreLibrariesStringSegment
The StringSegment to convert.
definedOnly (Optional)
Type: SystemBoolean
If , the result can only be a defined value in the specified TEnum type. If , the result can be a non-defined value, too.

Type Parameters

The type of the Enum.

Return Value

Type: NullableTEnum
A non- value if the conversion was successful; otherwise, .

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type StringSegment. 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).
See Also