Recently, I am coding a c# module (previously was written in vb.net), I found that "Collection Class" did NOT exist in c# but it can be found in vb.net !!
======================================
My Computer: .NetFramework 1.1 & VS.NET 2003
======================================
And therefore I am forcing myself to use the following methods to solve the "missing class" in c#
Step 1. Under the Solution Explorer, Add Reference "Microsoft.VisualBasic"
Step 2. Under the *.cs file, Type using Microsoft.VisualBasic;
Step 3: Under the *.cs file, Type Collection m_result = new Collection;
In fact, I can NATIVELY use Collection in vb.net
Dim m_results As New Collection
This is the way I can use Collection in c#. May I ask if any experts here can give me an answer what is the "suitable" way to have Collection? or Am I correct?
Here below is one of the functions (written in VB.NET) I use Collection and "grap" the data in the DAL Layer and use it for UI Layer:
----------------------------------------------------
Public Function GetBrands() As Collection
Dim m_da As New MySqlDataAdapter
Dim m_ds As New DataSet
Dim m_data As m_BrandData
Dim m_results As New Collection
Dim m_dataRow As DataRow
Dim m_SQL As String
m_SQL = "Select * From tb_Brand order by brandName"
m_da.SelectCommand =
New MySqlCommand(m_SQL, m_conn)
m_da.Fill(m_ds, "table1")
For Each m_dataRow In m_ds.Tables("table1").Rows
m_data =
New m_BrandData
With m_data
.brandCode =
CStr(m_dataRow.Item("brandCode"))
.brandName =
CStr(m_dataRow.Item("brandName"))
End With
m_results.Add(m_data)
m_data =
Nothing
Next
GetBrands = m_results
End Function
----------------------------------------------------How may I do the same thing in C#? Do I have to use Microsoft.VisualBasic reference (that's NOT native to me"?
Please advice