venerdì 16 settembre 2011

Vb net Entity e List T

Giusto perchè oggi mi sento bello carico e in vena di prove con Vb.Net ecco che mi cimento nel mio classico esempietto.

La mia Amorevole classe entity rivista in versione Vb.Net, mi rendo conto sempre più dello sforzo fatto da MS, per ottenere due linguaggi (differenti) a cui dare una certa somiglianza.

Mi pare però che le differenze ci siano e non troppo ben celate.

Public Class Entity

Private _idEntity As Integer
Private _EntityName As String
Private _EntityDescription As String

Public Property idEntity() As Integer
Get
Return _idEntity
End Get
Set(ByVal value As Integer)
_idEntity = value
End Set
End Property


Public Property EntityName() As String
Get
Return _EntityName
End Get
Set(ByVal value As String)
_EntityName = value
End Set
End Property


Public Property EntityDescription() As String
Get
Return _EntityDescription
End Get
Set(ByVal value As String)
_EntityDescription = value
End Set
End Property


End Class


Public Class Entities
Inherits List(Of Entity)

End Class


Tuttavia mi pare che a fronte di una sintassi non troppo differente il risultato
sia più o meno simile.

Tanto simili anche nell'utilizzo...

Module Module1

Sub Main()

Dim ent1 As New Entity()
Dim ent2 As New Entity()

ent1.idEntity = 1
ent1.EntityName = "C#"
ent1.EntityDescription = "il primo amore"

ent2.idEntity = 2
ent2.EntityName = "vb"
ent2.EntityDescription = "il primo linguaggio"


Dim ents As New Entities()

ents.Add(ent1)
ents.Add(ent2)


End Sub

End Module


Potrei farci l'abitudine

Nessun commento: