Converts the string representation of the name, CICA Code, or numeric value of one or more enumerated constants to an equivalent enumerated object.

Namespace:  BargeEx
Assembly:  BargeEx (in BargeEx.dll)
Version: 3.0.400.140 (3.0.400.140)

Syntax

C#
public static EnumType ParseEnumString<EnumType>(
	string value,
	EnumType defaultValue
)
where EnumType : struct
Visual Basic (Declaration)
Public Shared Function ParseEnumString(Of EnumType As Structure) ( _
	value As String, _
	defaultValue As EnumType _
) As EnumType
Visual C++
public:
generic<typename EnumType>
where EnumType : value class
static EnumType ParseEnumString(
	String^ value, 
	EnumType defaultValue
)

Parameters

value
Type: System..::.String
A string containing the name, CICA Code, or value to convert.
defaultValue
Type: EnumType
The value to return if the string cannot be successfully parsed.

Type Parameters

EnumType
The type of the enumeration to return.

Return Value

An EnumType whose value is represented by value.

Remarks

The value parameter contains a value, a named constant, a CICA Code, or a list of named constants delimited by commas (,). One or more blanks spaces can precede or follow each value, name, or comma in value. If value is a list, the return value is the value of the specified names combined with a bitwise OR operation.

This operation is not case-sensitive.

Examples

The following example declares a variable of type CicaDocumentErrorCode and sets it using the CICA Code string "RI".
CopyVisual Basic
' Declare ErrorCode variable
Dim ErrorCode As BargeEx.CicaDocumentErrorCode

' This will set ErrorCode to BargeEx.CicaDocumentErrorCode.ReferentialIntegrity
ErrorCode = BargeEx.Utilities.ParseEnumString("RI", BargeEx.CicaDocumentErrorCode.Invalid)
CopyC#
// Declare ErrorCode variable
BargeEx.CicaDocumentErrorCode ErrorCode;

// This will set ErrorCode to BargeEx.CicaDocumentErrorCode.ReferentialIntegrity
ErrorCode = BargeEx.Utilities.ParseEnumString("RI", BargeEx.CicaDocumentErrorCode.Invalid);

See Also