473,386 Members | 1,908 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,386 software developers and data experts.

How to merge Array

ad
I declare two string array:

string a1={"a", "b","c"};
string a2={"a", "b","c","d"};

Can I declare as
string a1={"a", "b","c"};
string a2=a1+{"d"};
The above is fail when compile, how can I do that?


Nov 17 '05 #1
8 12242

"ad" <fl****@wfes.tcc.edu.tw> wrote in message
news:Oh**************@TK2MSFTNGP09.phx.gbl...
I declare two string array:

string a1={"a", "b","c"};
string a2={"a", "b","c","d"};

Can I declare as
string a1={"a", "b","c"};
string a2=a1+{"d"};


You can't. You'll have to include each item manually or write code using
Array.CopyTo to do it.

You might also elect to use a list structure instead. If you are using 1.x
use ArrayList, in 2.0 you can use List<string> and call the Add method to
add a new entry to the list.
Nov 17 '05 #2

"Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in
message news:uT**************@TK2MSFTNGP09.phx.gbl...

"ad" <fl****@wfes.tcc.edu.tw> wrote in message
news:Oh**************@TK2MSFTNGP09.phx.gbl...
I declare two string array:

string a1={"a", "b","c"};
string a2={"a", "b","c","d"};

Can I declare as
string a1={"a", "b","c"};
string a2=a1+{"d"};

You can't. You'll have to include each item manually or write code using
Array.CopyTo to do it.

You might also elect to use a list structure instead. If you are using 1.x
use ArrayList, in 2.0 you can use List<string>


Did you mean to type "ArrayList<string> " or has List replaced ArrayListi n
2.0 ?
and call the Add method to add a new entry to the list.

Nov 17 '05 #3

"Mike Schilling" <ms*************@hotmail.com> wrote in message
news:e4**************@TK2MSFTNGP10.phx.gbl...

"Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in
message news:uT**************@TK2MSFTNGP09.phx.gbl...

"ad" <fl****@wfes.tcc.edu.tw> wrote in message
news:Oh**************@TK2MSFTNGP09.phx.gbl...
I declare two string array:

string a1={"a", "b","c"};
string a2={"a", "b","c","d"};

Can I declare as
string a1={"a", "b","c"};
string a2=a1+{"d"};


You can't. You'll have to include each item manually or write code using
Array.CopyTo to do it.

You might also elect to use a list structure instead. If you are using
1.x use ArrayList, in 2.0 you can use List<string>


Did you mean to type "ArrayList<string> " or has List replaced ArrayListi
n 2.0 ?


It was List<string> as of beta 2. I havn't grabbed any of the more recent
builds so it could have changed, but I'd be surprised if it did.

It is Dictionary<T> instead of Hashtable now as well. The generic
collection's are a little better thought out.
Nov 17 '05 #4
Daniel O'Connell [C# MVP] <onyxkirx@--NOSPAM--comcast.net> wrote:

<snip>
It is Dictionary<T> instead of Hashtable now as well. The generic
collection's are a little better thought out.


Except SortedList, which is still called a list despite fundamentally
being a map :(

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 17 '05 #5

"Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in
message news:%2****************@TK2MSFTNGP09.phx.gbl...

"Mike Schilling" <ms*************@hotmail.com> wrote in message
news:e4**************@TK2MSFTNGP10.phx.gbl...

"Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in
message news:uT**************@TK2MSFTNGP09.phx.gbl...

"ad" <fl****@wfes.tcc.edu.tw> wrote in message
news:Oh**************@TK2MSFTNGP09.phx.gbl...
I declare two string array:

string a1={"a", "b","c"};
string a2={"a", "b","c","d"};

Can I declare as
string a1={"a", "b","c"};
string a2=a1+{"d"};
You can't. You'll have to include each item manually or write code using
Array.CopyTo to do it.

You might also elect to use a list structure instead. If you are using
1.x use ArrayList, in 2.0 you can use List<string>


Did you mean to type "ArrayList<string> " or has List replaced ArrayListi
n 2.0 ?


It was List<string> as of beta 2. I havn't grabbed any of the more recent
builds so it could have changed, but I'd be surprised if it did.

It is Dictionary<T> instead of Hashtable now as well. The generic
collection's are a little better thought out.


Interesting. Are the 2.0 class library docs available online?
Nov 17 '05 #6
Mike Schilling <ms*************@hotmail.com> wrote:
It was List<string> as of beta 2. I havn't grabbed any of the more recent
builds so it could have changed, but I'd be surprised if it did.

It is Dictionary<T> instead of Hashtable now as well. The generic
collection's are a little better thought out.


Interesting. Are the 2.0 class library docs available online?


Absolutely - the easiest way to get them is probably to get the 2.0
SDK:

http://www.microsoft.com/downloads/d...fe6f2099-b7b4-
4f47-a244-c96d69c35dec&DisplayLang=en

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 17 '05 #7

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP***********************@msnews.microsoft.co m...
Mike Schilling <ms*************@hotmail.com> wrote:
> It was List<string> as of beta 2. I havn't grabbed any of the more
> recent
> builds so it could have changed, but I'd be surprised if it did.
>
> It is Dictionary<T> instead of Hashtable now as well. The generic
> collection's are a little better thought out.


Interesting. Are the 2.0 class library docs available online?


Absolutely - the easiest way to get them is probably to get the 2.0
SDK:

http://www.microsoft.com/downloads/d...fe6f2099-b7b4-
4f47-a244-c96d69c35dec&DisplayLang=en


Yes, I know how to do that. My memories of how to de-install the 1.0 beta
(re-format the hard disk, and no, I am not making this up) are still fresh
enough that I'd prefer not to.
Nov 17 '05 #8
Mike Schilling <ms*************@hotmail.com> wrote:
http://www.microsoft.com/downloads/d...fe6f2099-b7b4-
4f47-a244-c96d69c35dec&DisplayLang=en


Yes, I know how to do that. My memories of how to de-install the 1.0 beta
(re-format the hard disk, and no, I am not making this up) are still fresh
enough that I'd prefer not to.


I've removed beta 2 of 2.0 without problem before. And besides, aren't
you going to want to go to 2.0 at some point anyway?

If you want to just use the online version though, you can go to
http://msdn2.microsoft.com

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 17 '05 #9

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

Similar topics

3
by: Kevin King | last post by:
I have a question about an assignment I have. I need to count the number of comparisons in my merge sort. I know that the function is roughly nlog(n), but I am definately coming up with too many...
2
by: Mamidinx | last post by:
Hi, With the MERGE statement I am using in DB2 it rolls back all the way if an error is encountered. Is there a way to save each of the encountered exception but proceed to the next data record...
9
by: rkk | last post by:
Hi, I have written a generic mergesort program which is as below: --------------------------------------------------------- mergesort.h ----------------------- void MergeSort(void...
13
by: ralphedge | last post by:
These sorts work fine on 100000 ints but if I go much higher they will both segmentation fault **************************MERGESORT********************* mergesort(int *a, int size) //a is...
1
by: mr k | last post by:
Hi, I wanted to use mail merge with forms but Text form fields are not retained during mail merge in Word, I got the code from Microsoft but it doesn't remember the text form field options such as...
7
by: Zeba | last post by:
Hi, I have to write program in C# to merge sort a linked list (doubly linked). Is it true that the best way to do it is copy it into an array, sort it and then convert back ? I'm new to C#,...
2
by: mqueene7 | last post by:
below is my code for my merge sort but I can't get it to sort properly. I am trying generate random numbers based on input from the user and then sort those random numbers. Can you tell me what I...
3
by: mimosabg | last post by:
Hi all, I've just copy a part of C source code for my C applet. My program is about merge sort and array implementation. When I run, I find that it has a lot of errors. Even I try my best to fix...
7
by: mooon33358 | last post by:
I have a little problem with implementing a recursive merge sort I have to use a function mergesort that takes 3 arguments - an array, its size, and an help array(i.e mergesort(int array, int...
24
by: Henry J. | last post by:
My app needs to insert thousand value rows into a mostly empty table (data are read from a file). I can either use inserts, or use merge. The advantage of using merge is that in the few cases...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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
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...

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.