473,394 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

how to translate that vb code in C#

HI

I 've been trying to find the equivalent code in C# but I did not succeed.
What is the equivalent of Collection in C#?

Dim c_colNewCustomerDataRows As New Collection()
If c_colNewCustomerDataRows.Count > 0 Then
Dim drCustomers As DataSet1.CustomersRow
For Each drCustomers In c_colNewCustomerDataRows
DataSet11.Customers.Rows.Add(drCustomers)
Next
End If

Thanks
Nov 15 '05 #1
6 1255
arnold,

You can actually use the Collection class in C#, by setting a reference
to Microsoft.VisualBasic.dll. However, I don't think that this is a good
idea.

The better object, in my opinion, is the Hashtable. This is slightly
different than the Collection class in VB, because it allows any type to be
used as a key, not just strings. However, you can not access the items
using a numeric indexer, so if that is important to you (and the keys
aren't), then use the ArrayList class.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"arnold" <ar****@freesurf.fr> wrote in message
news:Ol**************@TK2MSFTNGP12.phx.gbl...
HI

I 've been trying to find the equivalent code in C# but I did not succeed.
What is the equivalent of Collection in C#?

Dim c_colNewCustomerDataRows As New Collection()
If c_colNewCustomerDataRows.Count > 0 Then
Dim drCustomers As DataSet1.CustomersRow
For Each drCustomers In c_colNewCustomerDataRows
DataSet11.Customers.Rows.Add(drCustomers)
Next
End If

Thanks

Nov 15 '05 #2
It should look something like this:

Collection c_colNewCustomerDataRows = new Collection();

if(c_colNewCustomerDataRows.Count > 0)
{
foreach(DataSet1.CustomersRow drCustomers in c_colNewCustomerDataRows)
{
DataSet11.Customers.Rows.Add(drCustomers);
}
}

Hm, did I send this already or forgot it? In case of duplicate I
apologize.

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
For a laugh, try web browsing with Opera's User Mode and Nostalgia enabled
Nov 15 '05 #3

"arnold" <ar****@freesurf.fr> wrote in message
news:Ol**************@TK2MSFTNGP12.phx.gbl...
HI

I 've been trying to find the equivalent code in C# but I did not succeed.
What is the equivalent of Collection in C#?

Dim c_colNewCustomerDataRows As New Collection() If c_colNewCustomerDataRows.Count > 0 Then
Dim drCustomers As DataSet1.CustomersRow
For Each drCustomers In c_colNewCustomerDataRows
DataSet11.Customers.Rows.Add(drCustomers)
Next
End If

Collection c_colNewCustomerDataRows = new Collection();
if (c_colNewCustomerDataRows.Count > 0)
{
foreach (DataSet1.CustomersRow drCustomers In c_colNewCustomerDataRows)
DataSet11.Customers.Rows.Add(drCustomers)
}

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com
Nov 15 '05 #4
You'll need a reference to the Microsoft.VisualBasic.dll for the Collection
class.
Collection c_colNewCustomerDataRows = new Collection();
if(c_colNewCustomerDataRows.Count > 0)
{
DataSet1.CustomersRow drCustomers;
foreach(drCustomers in c_colNewCustomerDataRows)
{
DataSet1.Customers.Rows.Add(drCustomers);
}
}

Since I don't have access to your objects, I haven't been able to check it.
Anyway, I think you won't need the if statement.

--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan
"arnold" <ar****@freesurf.fr> wrote in message
news:Ol**************@TK2MSFTNGP12.phx.gbl...
HI

I 've been trying to find the equivalent code in C# but I did not succeed.
What is the equivalent of Collection in C#?

Dim c_colNewCustomerDataRows As New Collection()
If c_colNewCustomerDataRows.Count > 0 Then
Dim drCustomers As DataSet1.CustomersRow
For Each drCustomers In c_colNewCustomerDataRows
DataSet11.Customers.Rows.Add(drCustomers)
Next
End If

Thanks

Nov 15 '05 #5

Thanks for you answer. But there is no class Collection in C# and so I
would like to use an equivalent class in C#.
I would prefer not to use a reference to the Microsoft.VisualBasic.dll

I do not know how to use neither the HashTable nor the Arraylist for my
case.
I tried to use the Hashtable but when I do :
DataSet1.CustomersRow drCustomers;
foreach(drCustomers in c_colNewCustomerDataRows)
That give an error because the 2 parameter are not the same type.
I tried so ( foreach(drCustomers in (DataRow) c_colNewCustomerDataRows) but
that doesn't accept the conversion.

Thanks


"Jan Tielens" <ja*@no.spam.please.leadit.be> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
You'll need a reference to the Microsoft.VisualBasic.dll for the Collection class.
Collection c_colNewCustomerDataRows = new Collection();
if(c_colNewCustomerDataRows.Count > 0)
{
DataSet1.CustomersRow drCustomers;
foreach(drCustomers in c_colNewCustomerDataRows)
{
DataSet1.Customers.Rows.Add(drCustomers);
}
}

Since I don't have access to your objects, I haven't been able to check it. Anyway, I think you won't need the if statement.

--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan
"arnold" <ar****@freesurf.fr> wrote in message
news:Ol**************@TK2MSFTNGP12.phx.gbl...
HI

I 've been trying to find the equivalent code in C# but I did not succeed. What is the equivalent of Collection in C#?

Dim c_colNewCustomerDataRows As New Collection()
If c_colNewCustomerDataRows.Count > 0 Then
Dim drCustomers As DataSet1.CustomersRow
For Each drCustomers In c_colNewCustomerDataRows
DataSet11.Customers.Rows.Add(drCustomers)
Next
End If

Thanks


Nov 15 '05 #6
Hi arnold,

ArrayList is an equivalent (and better) of Collection.

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

"arnold" <ar****@freesurf.fr> wrote in message
news:uT**************@TK2MSFTNGP12.phx.gbl...

Thanks for you answer. But there is no class Collection in C# and so I
would like to use an equivalent class in C#.
I would prefer not to use a reference to the Microsoft.VisualBasic.dll

I do not know how to use neither the HashTable nor the Arraylist for my
case.
I tried to use the Hashtable but when I do :
DataSet1.CustomersRow drCustomers;
foreach(drCustomers in c_colNewCustomerDataRows)
That give an error because the 2 parameter are not the same type.
I tried so ( foreach(drCustomers in (DataRow) c_colNewCustomerDataRows) but that doesn't accept the conversion.

Thanks


"Jan Tielens" <ja*@no.spam.please.leadit.be> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
You'll need a reference to the Microsoft.VisualBasic.dll for the

Collection
class.
Collection c_colNewCustomerDataRows = new Collection();
if(c_colNewCustomerDataRows.Count > 0)
{
DataSet1.CustomersRow drCustomers;
foreach(drCustomers in c_colNewCustomerDataRows)
{
DataSet1.Customers.Rows.Add(drCustomers);
}
}

Since I don't have access to your objects, I haven't been able to check

it.
Anyway, I think you won't need the if statement.

--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan
"arnold" <ar****@freesurf.fr> wrote in message
news:Ol**************@TK2MSFTNGP12.phx.gbl...
HI

I 've been trying to find the equivalent code in C# but I did not succeed. What is the equivalent of Collection in C#?

Dim c_colNewCustomerDataRows As New Collection()
If c_colNewCustomerDataRows.Count > 0 Then
Dim drCustomers As DataSet1.CustomersRow
For Each drCustomers In c_colNewCustomerDataRows
DataSet11.Customers.Rows.Add(drCustomers)
Next
End If

Thanks



Nov 15 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Bengt Richter | last post by:
Just thought None as the first argument would be both handy and mnemonic, signifying no translation, but allowing easy expression of deleting characters, e.g., s = s.translate(None,...
1
by: Xeon | last post by:
Hi, I'm trying to replace spaces with %20 with help of translate, but not successfull. Here's a node in the xml file : <title>This is some test title</title> The xsl code I'm using : ...
7
by: Johnny Lee | last post by:
Hi, First, I want to know whether the python interpreter translate the code directly into machine code, or translate it into C then into machine code? Second, if the codes are translated directly...
6
by: VBTricks.de.vu Webmaster | last post by:
Hello, in VB6 I used to translate my application by setting the tag-property of all controls, menu-entries... to a number which has been linked to a string (array). Then I went through all...
6
by: bobueland | last post by:
The module string has a function called translate. I tried to find the source code for that function. In: C:\Python24\Lib there is one file called string.py I open it and it says
1
by: peterbe | last post by:
This has always worked fine for me. Peter fine Now if I do it with a unicode string: Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/lib/python2.4/string.py", line...
9
bvdet
by: bvdet | last post by:
I have done some more work on a simple class I wrote to calculate a global coordinate in 3D given a local coordinate: ## Basis3D.py Version 1.02 (module macrolib.Basis3D) ## Copyright (c) 2006...
3
by: amija0311 | last post by:
Hi, I am new using DB2 9.1 database by windows base. I want to query the data that contain string then translate the string into integer using DB2. The problems is If the data is null, i got the...
3
by: Kenneth McDonald | last post by:
I have the need to occasionally translate a single word programatically. Would anyone have a Python script that would let me do this using Google (or another) translation service? Thanks, Ken
4
by: kovariadam | last post by:
Hi, Does anybody know why i get this error: SQL0176N The second, third or fourth argument of the TRANSLATE scalar function is incorrect. SQLSTATE=42815 with this query: SELECT...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.