System Namespace Enum Class
Converts the value of this instance to its equivalent string representation.
Converts the value of this instance to its equivalent string representation.
Converts the value of this instance to its equivalent string representation using the specified format information.
Converts the value of this instance to its equivalent string representation using the specified format.
Converts the value of this instance to its equivalent string representation using the specified format and format information.
The following code example demonstrates converting an enumerated value to a string.
NOTE: This example shows how to use one of the overloaded versions of ToString. For other examples that might be available, see the individual overload topics.
[ VB ]
Imports System
Public Class EnumSample
Enum Colors
Red = 1
Blue = 2
End Enum
Public Shared Sub Main ( )
Dim myColors As Colors = Colors.Red
Response.WriteLine ( "The value of this instance is '{0}'", _
myColors.ToString ( ) )
End Sub
End Class
'Output.
'The value of this instance is 'Red'.
[ C# ]
using System;
public class EnumSample {
enum Colors {Red = 1, Blue = 2};
public static void Main ( ) {
Enum myColors = Colors.Red;
Response.WriteLine ( "The value of this instance is '{0}'",
myColors.ToString ( ) );
}
}
/*
Output.
The value of this instance is 'Red'.
*/
[ C++, JScript ] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button in the upper-left corner of the page.
Enum Members