Public Class GetValuesTest
Enum Colors
Red
Green
Blue
Yellow
End Enum 'Colors
Enum Styles
Plaid = 0
Striped = 23
Tartan = 65
Corduroy = 78
End Enum 'Styles
Public Shared Sub Main()
Console.WriteLine("The values of the Colors Enum are:")
Dim i As Integer
For Each i In [Enum].GetValues(GetType(Colors))
Console.WriteLine(i)
Next
Console.WriteLine()
Console.WriteLine("The values of the Styles Enum are:")
For Each i In [Enum].GetValues(GetType(Styles))
Console.WriteLine(i)
Next
End Sub
End Class
' The example produces the following output:
' The values of the Colors Enum are:
' 0
' 1
' 2
' 3
'
' The values of the Styles Enum are:
' 0
' 23
' 65
' 78
using System;
public class GetValuesTest {
enum Colors { Red, Green, Blue, Yellow };
enum Styles { Plaid = 0, Striped = 23, Tartan = 65, Corduroy = 78 };
public static void Main() {
Console.WriteLine("The values of the Colors Enum are:");
foreach(int i in Enum.GetValues(typeof(Colors)))
Console.WriteLine(i);
Console.WriteLine();
Console.WriteLine("The values of the Styles Enum are:");
foreach(int i in Enum.GetValues(typeof(Styles)))
Console.WriteLine(i);
}
}
// The example produces the following output:
// The values of the Colors Enum are:
// 0
// 1
// 2
// 3
//
// The values of the Styles Enum are:
// 0
// 23
// 65
// 78
using namespace System;
enum class Colors
{
Red, Green, Blue, Yellow
};
enum class Styles
{
Plaid = 0,
Striped = 23,
Tartan = 65,
Corduroy = 78
};
int main()
{
Console::WriteLine( "The values of the Colors Enum are:" );
Array^ a = Enum::GetValues( Colors::typeid );
for ( Int32 i = 0; i < a->Length; i++ )
{
Object^ o = a->GetValue( i );
Console::WriteLine( "{0}", Enum::Format( Colors::typeid, o, "D" ) );
}
Console::WriteLine();
Console::WriteLine( "The values of the Styles Enum are:" );
Array^ b = Enum::GetValues( Styles::typeid );
for ( Int32 i = 0; i < b->Length; i++ )
{
Object^ o = b->GetValue( i );
Console::WriteLine( "{0}", Enum::Format( Styles::typeid, o, "D" ) );
}
}
// The example produces the following output:
// The values of the Colors Enum are:
// 0
// 1
// 2
// 3
//
// The values of the Styles Enum are:
// 0
// 23
// 65
// 78
import System.*;
public class GetValuesTest
{
enum Colors
{
red (0),
green (1),
blue (2),
yellow (3);
} //Colors
enum Styles
{
plaid (0),
striped (23),
tartan (65),
corduroy (78);
} //Styles
public static void main(String[] args)
{
Console.WriteLine("The values of the Colors Enum are:");
Array a = Enum.GetValues(Colors.class.ToType());
for (int iCtr = 0; iCtr < a.get_Length(); iCtr++) {
Int32 i =( Int32)a.GetValue(iCtr);
Console.WriteLine(i);
}
Console.WriteLine();
Console.WriteLine("The values of the Styles Enum are:");
Array a1 = Enum.GetValues(Styles.class.ToType());
for (int iCtr = 0; iCtr < a1.get_Length(); iCtr++) {
Int32 i =( Int32)a1.GetValue(iCtr);
Console.WriteLine(i);
}
} //main
} //GetValuesTest
// The example produces the following output:
// The values of the Colors Enum are:
// 0
// 1
// 2
// 3
//
// The values of the Styles Enum are:
// 0
// 23
// 65
// 78
import System;
public class GetValuesTest {
enum Colors { Red, Green, Blue, Yellow };
enum Styles { Plaid = 0, Striped = 23, Tartan = 65, Corduroy = 78 };
public static function Main() {
Console.WriteLine("The values of the Colors Enum are:");
for(var i : int in Enum.GetValues(Colors))
Console.WriteLine(Enum.GetValues(Colors).GetValue(i));
Console.WriteLine();
Console.WriteLine("The values of the Styles Enum are:");
for(var j : int in Enum.GetValues(Styles))
Console.WriteLine(Enum.GetValues(Styles).GetValue(j));
}
}
// The example produces the following output:
// The values of the Colors Enum are:
// 0
// 1
// 2
// 3
//
// The values of the Styles Enum are:
// 0
// 23
// 65
// 78