strange ,,,
changing structures to classes seems a bit odd to me as the TS might have a
good reasson to choose for a structure
when you do not need instancing , and ther are no actuall methods ( so the
struct only holds values ) i prefer to use structures also structures are
faster as classes in this case ( stack vs heap ) and more lightweight so
they seem perfect for this task.
I use structures in a hashtable , and i program always with option explicit
and option strict on
strange thingy i do not encounter this problem with a collection
Option Explicit On
Option Strict On
Public Class Form1
Inherits System.Windows.Forms.Form
Private Structure test
Friend a As String
Friend b As String
End Structure
Private sCol As Collection
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
sCol = New Collection
For i As Integer = 1 To 100
Dim strTest As New test
With strTest
..a = i.ToString
..b = "just a test"
End With
sCol.Add(sCol, i.ToString)
Next i
MsgBox("finished")
End Sub
End Class
regards
Michel Posseth [MCP]
<za***@construction-imaging.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
A common programming technique I use in VB is making a collection of
structures. But if Option Strict is on (which I would prefer), the .Add
that adds the structure to the collection is flagged with a compiler
error (invalid type conversion). Is there a way to use a collection of
structures WITH the Option Strict On?