473,486 Members | 2,429 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how to add arrays to Ilist

hey friends i am new to C# lang. can anybody tell me how to add arrays
to Ilist and how to get the values from the list( means) how to
traverse the list plz help me...
Apr 2 '08 #1
1 2756
Do you want to add the array to a list, or do you want to add the
*content* of the array to the list; i.e. if I have:

// array
int[] myInts = {1,2,3};

if we add that to an empty list, do you want 1 item in the list (which
is an array), or do you want 3 items in the list (the integers)?

I would recommend using generics here, such as List<T>; for example:

List<intmyList = new List<int>();
// ...
myList.AddRange(myInts);

For traversing the list, "foreach" is your friend, as it works for any
IEnumerable[/<T>] instance:

foreach (int i in myList)
{
Console.WriteLine(i);
}

Note you can also use "foreach" over myInts; the advantage of a list
is that you can add/remove items (arrays are fixed-size).

Marc

Apr 2 '08 #2

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

Similar topics

6
10941
by: Yanhao Zhu | last post by:
Hi, all, If I have an array like int m = new int { 0, 1, 2, 3 }, is there a way I can separate the array into two, like int m01 = somefunction?(m,0,2) // m01 will hold 1st and 2nd items in...
10
5411
by: Liz - Newbie | last post by:
Does anyone know how to clear arrays? My C# books talk about creating arrays or talk about using Clear or RemoveAt but these methods don't appear to be available for my array. I have an array...
18
39956
by: Mike Bartels | last post by:
Hi Everyone! I have two Arrays A and B. Both arrays are byte arrays with 7 bytes each. The contents of array A and B are the same A = {1, 2, 3, 4, 5, 6, 7}; B = {1, 2, 3, 4, 5, 6, 7}; When...
4
2978
by: Macin | last post by:
Hi, How to efficently divide big array into small arrays as showed below? IN xxxxxxxxxxxxxx xxxxx xxxxx xxxxx xxxxxxxxxxxxxx xxxxx xxxxx xxxxx...
1
4139
by: Michael Fitzpatrick | last post by:
Transferring arrays from C DLL's to VB.Net I have a DLL written in C. This DLL reads a text file and creates a several very large arrays, 500,000 points and even larger. I would like the get the...
11
1547
by: Gene | last post by:
I want to create a certain number of arrays on the same time to use, is it possible to do that?
9
1577
by: Steve | last post by:
Hello, I created a structure ABC and an array of type ABC Public Structure ABC Dim str1 As String Dim int1 As Integer End Structure Public ABC1 As New ABC, ABC2 As New ABC
2
7886
by: chris | last post by:
I have a few byte arrays that I would like to combine into one array (order needs to be kept). What would be the most efficient way to do this? Thanks for your time, Chris
19
2129
by: John Whitworth | last post by:
Hi, Firstly, apologies if what I am asking seems really obvious. I'm a self-taught VB2008 (via VB4, VB6 and VB2003) user, and have always just picked up what I need to know, when I need to know...
0
6967
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...
0
7132
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7180
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5439
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4870
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4564
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3076
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
600
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.