How to understand < of T as structure>

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

how to understand the following declaration in MSDN about nullable structure


<SerializableAttribute> _
Public Structure Nullable(Of T As Structure)

I can : dim id as nullable(of integer), but integer is not a structure, so
what is the function of the AS Structure here?

Clara
thank you so much for your help
 
Hi all,

how to understand the following declaration in MSDN about nullable structure

<SerializableAttribute> _
Public Structure Nullable(Of T As Structure)

I can : dim id as nullable(of integer), but integer is not a structure, so
what is the function of the AS Structure here?

Clara
thank you so much for your help

Actually, Integer is a structure. Integer maps to the System.Int32
datatype - which, if you look at the docs is declared:

<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public Structure Int32
Implements IComparable, IFormattable, IConvertible, IComparable(Of
Integer), _
IEquatable(Of Integer)

Essentually, the constraint is saying to allow T to be anything that
inherits from System.ValueType.

HTH
 
Perhaps a structure that you must define ?


<SerializableAttribute> _
Public Structure Nullable(Of T As Structure)

Public structure Blabla
Dim A as string
Dim B as integer
Dim C as boolean
'-- etc whatever
End structure

Public Structure Nullable(Of T As Blabla)






:-)

hth

Michel
 
clara said:
Hi all,

how to understand the following declaration in MSDN about nullable
structure


<SerializableAttribute> _
Public Structure Nullable(Of T As Structure)

I can : dim id as nullable(of integer), but integer is not a
structure, so what is the function of the AS Structure here?

Clara
thank you so much for your help

"Structure" is a constraint. It means a value type. Integer is a value type.
See section "constraints":
http://msdn2.microsoft.com/en-us/library/w256ka79(VS.80).aspx

http://msdn2.microsoft.com/en-us/library/ms172929(VS.80).aspx


Armin
 
Back
Top