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... 1 2780
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.WriteLi ne(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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 array m
int m23 = somefunction?(m,2,2) // m23 will hold srd and 4th items
in array m ,
and &m01 = &m, &m23 = &m + 2, always, (& is the get address of operation)
|
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 of client objects called aClients
if I try aClients.RemoveAt I get an error
"System.Array" does not contain a definition
for "RemoveAt".
|
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 I do
|
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
xxxxxxxxxxxxxx ==>> xxxxx xxxxx xxxxx
xxxxxxxxxxxxxx
|
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
data in VB.Net so that I can plot it. Presently I am creating an equally
sized array in VB and copying the data from the DLL's array into the VB
array.
There must be a better way. I looked into using a SAFEARRAY but it looks to
me that VB.Net...
| |
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?
|
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
|
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
|
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 it.
I'm writing an application that needs to be able to store several sets of
tagged data. Effectively, it's a two-dimensional array. I have created this,
but it is unwieldly to work with, as I have had to create it with a maximum
second...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |