Following on from the thread "another generic query", what is the
simplest way to implement Nullable(Of String) when that IS what you
want.

E.g. You have a String property and setting it to any value, including
Nothing, needs to be differentiated from its default value say.

I decided to create

Structure Box(Of T)
 Public Value As T
End Structure

Then I can use Nullable(Of Box(Of String))

which isn't that convoluted...

Does Box exist somewhere in the framework?

Is there a better way?

Regards,
Mark Hurd, B.Sc.(Ma.)(Hons.)

PS The more complete solution I'm using is:

Structure Box(Of T)
 Public Sub New(ByVal Value As T)
  Me.Value = Value
 End Sub
 Public ReadOnly Value As T
End Structure
...
Private SomeField As Nullable(Of Box(Of String))) = Nothing
...
If SomeField.HasValue Then Use(SomeField.Value.Value)

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to