Posted By

lfbarbieri on 02/05/07


Tagged

String enum Enumerations CompletionList


Versions (?)

String Enumerations


 / Published in: VB.NET
 

URL: http://dotnet.mvps.org/dotnet/faqs/?id=anytypeenums&lang=en

  1. 'http://dotnet.mvps.org/dotnet/faqs/?id=anytypeenums&lang=en
  2. '
  3. ''' <completionlist cref="T:StringEnum.ClipboardType" /> ' This makes Intellisense work
  4. <Serializable()> _
  5. Public Structure ClipboardType
  6.  
  7. #Region "Member Variables"
  8.  
  9. Private m_Value As String
  10.  
  11. #End Region
  12.  
  13. #Region "Constructor"
  14.  
  15. Private Sub New(ByVal Value As String)
  16. m_Value = Value
  17. End Sub
  18.  
  19. #End Region
  20.  
  21. #Region "Public Methods"
  22.  
  23. Public Overrides Function ToString() As String
  24. Return m_Value
  25. End Function
  26.  
  27.  
  28. Public Overloads Overrides Function Equals(ByVal obj As Object) As Boolean
  29. Return DirectCast(obj, ClipboardType).ToString() = m_Value
  30. End Function
  31.  
  32. ' '=' Operator overloading stuff (VB 2005).
  33. Public Shared Operator =(ByVal left As ClipboardType, ByVal right As ClipboardType) As Boolean
  34. Return left.m_Value = right.m_Value
  35. End Operator
  36.  
  37. Public Shared Operator <>(ByVal left As ClipboardType, ByVal right As ClipboardType) As Boolean
  38. Return left.m_Value <> right.m_Value
  39. End Operator
  40.  
  41. #End Region
  42.  
  43. #Region "Enumerations"
  44.  
  45. Public Shared ReadOnly Property Rtf() As ClipboardType
  46. Get
  47. Return New ClipboardType("RTF")
  48. End Get
  49. End Property
  50.  
  51. Public Shared ReadOnly Property Bitmap() As ClipboardType
  52. Get
  53. Return New ClipboardType("Bitmap")
  54. End Get
  55. End Property
  56.  
  57. Public Shared ReadOnly Property Text() As ClipboardType
  58. Get
  59. Return New ClipboardType("Text")
  60. End Get
  61. End Property
  62.  
  63. Public Shared ReadOnly Property Garble() As ClipboardType
  64. Get
  65. Return New ClipboardType("Garble")
  66. End Get
  67. End Property
  68.  
  69. ' OR This works too
  70. 'Public Shared ReadOnly Rtf As New ClipboardType("RTF")
  71. 'Public Shared ReadOnly Bitmap As New ClipboardType("Bitmap")
  72. 'Public Shared ReadOnly Text As New ClipboardType("Text")
  73. 'Public Shared ReadOnly Garble As New ClipboardType("Garble")
  74.  
  75. #End Region
  76.  
  77. End Structure

Report this snippet  

You need to login to post a comment.