Convert Enum element to int and call ToString : Enum « Data Types « VB.Net






Convert Enum element to int and call ToString

Convert Enum element to int and call ToString
 
Imports System
Imports System.Data
Imports System.Collections

public class MainClass
   Shared Sub Main()
        Dim I1, I2, I3 As Integer
        I1 = E.A : I2 = E.B : I3 = E.C

        Console.WriteLine(I1.ToString() &" " & I2.ToString() &" " & I3.ToString())

   End Sub
End Class

    Enum E
        A = 5
        B
        C = 6   ' B and C will both be 6
    End Enum

           
         
  








Related examples in the same category

1.Convert Element in Enum to IntegerConvert Element in Enum to Integer
2.Enum TemperaturesEnum Temperatures
3.Convert Enum to IntConvert Enum to Int
4.Use Enum to define Access LevelUse Enum to define Access Level
5.Enum data DemoEnum data Demo
6.Enum Class provides the base class for enumerations.
7.Using type to convert integer to Enum
8.Convert Enum value back and forth
9.Check if the backend value is defined for an Enum
10.Get Enum underline type
11.Enum parse String value to Enum
12.Use TryParse to parse string value to Enum
13.Get Enum value names
14.Get Enum values
15.Flag Enum values
16.Or operation on Flag enum value
17.And Operation on Flag enum value
18.Equals comparison for Enum value
19.The days of the week, and their corresponding values in the Days Enum
20.Output the enum underline values
21.Combine the flag enum values
22.Enum.CompareTo compares this instance to a specified object and returns an indication of their relative values.
23.Enum.Equals Method returns a value indicating whether this instance is equal to a specified object.
24.Enum.GetName Method retrieves the name of the constant in the specified enumeration that has the specified value.
25.Enum.GetNames Method retrieves an array of the names of the constants in a specified enumeration.
26.Enum.GetValues Method retrieves an array of the values of the constants in a specified enumeration.
27.Enum.HasFlag Method tells whether one or more bit fields are set in the current instance.
28.Check flag Enum combination
29.Enum.IsDefined Method tells whether a constant with a specified value exists in a specified enumeration.
30.Call IsDefined with invalid underlying integral value.
31.Call IsDefined with string containing member name.
32.Call IsDefined with a variable of type PetType.
33.Call IsDefined with uppercase member name.
34.Call IsDefined with combined value
35.Enum.Parse Method converts string to an enumerated object.
36.Enum.Parse Method converts string to enumerated object
37.Sample for Enum.ToString(String)
38.Enum.ToString Method converts the value to string representation.
39.Convert Enum value to string with ToString method
40.Enum.TryParse(TEnum) converts string to enumerated object
41.Enum.TryParse(TEnum) converts string to enumerated object
42.Enum value ToString: G F D X
43.FlagsAttribute Indicates that an enumeration can be treated as a bit field; that is, a set of flags.