Silverlight 3 GetName

Wie Kollege Fischer in einem Blog Eintrag anmerkt, soll in einer Aufzählung GetName fehlen. Mit GetName kann man den Namen in einer Enumeration (Liste) herausfinden. Die SL 3 Doku beschreibt das jedenfalls.

Methode aus Enum

 

  GetName Retrieves the name of the constant in the specified enumeration that has the specified value.

Public Class Example

   Enum Colors
      Red
      Green
      Blue
      Yellow
   End Enum 'Colors

   Enum Styles
      Plaid
      Striped
      Tartan
      Corduroy
   End Enum 'Styles

   Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
      outputBlock.Text += String.Format("The 4th value of the Colors Enum is {0}", [Enum].GetName(GetType(Colors), 3)) & vbCrLf
      outputBlock.Text += String.Format("The 4th value of the Styles Enum is {0}", [Enum].GetName(GetType(Styles), 3)) & vbCrLf
   End Sub 'Main
End Class 'GetNameTest

Kommentare sind geschlossen