473,503 Members | 2,142 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Put array values into a single variable

I like to put all the values of an array into a single variable like:

networkFiles = "val 1
val 2
val 3
val 4
val 5";

Here is what i am doing, but getting error message:
Operator '+' cannot be applied to operand of type 'string'

string networkFiles;
networkFiles = "";

for(int i; i < localDrive.Length; i++)
{
networkFiles = + localDrive[i];
localFiles = + Environment.NewLine;
}

Please help
Nov 19 '05 #1
4 3088
oops.. the code should be:

for(int i; i < localDrive.Length; i++)
{
networkFiles = + localDrive[i];
networkFiles = + Environment.NewLine;
}
"huzz" wrote:
I like to put all the values of an array into a single variable like:

networkFiles = "val 1
val 2
val 3
val 4
val 5";

Here is what i am doing, but getting error message:
Operator '+' cannot be applied to operand of type 'string'

string networkFiles;
networkFiles = "";

for(int i; i < localDrive.Length; i++)
{
networkFiles = + localDrive[i];
localFiles = + Environment.NewLine;
}

Please help

Nov 19 '05 #2
You want += not =+

and why not just use

networkFiles = String.Join("\n", localDrive);

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"huzz" <hu**@discussions.microsoft.com> wrote in message
news:41**********************************@microsof t.com...
oops.. the code should be:

for(int i; i < localDrive.Length; i++)
{
networkFiles = + localDrive[i];
networkFiles = + Environment.NewLine;
}
"huzz" wrote:
I like to put all the values of an array into a single variable like:

networkFiles = "val 1
val 2
val 3
val 4
val 5";

Here is what i am doing, but getting error message:
Operator '+' cannot be applied to operand of type 'string'

string networkFiles;
networkFiles = "";

for(int i; i < localDrive.Length; i++)
{
networkFiles = + localDrive[i];
localFiles = + Environment.NewLine;
}

Please help

Nov 19 '05 #3
I believe the operator should be +=, not =+. If you run into implicit
casting problems, use the ToString method that every object has.

Hope this helps,
Johann MacDonagh

"huzz" <hu**@discussions.microsoft.com> wrote in message
news:41**********************************@microsof t.com...
oops.. the code should be:

for(int i; i < localDrive.Length; i++)
{
networkFiles = + localDrive[i];
networkFiles = + Environment.NewLine;
}
"huzz" wrote:
I like to put all the values of an array into a single variable like:

networkFiles = "val 1
val 2
val 3
val 4
val 5";

Here is what i am doing, but getting error message:
Operator '+' cannot be applied to operand of type 'string'

string networkFiles;
networkFiles = "";

for(int i; i < localDrive.Length; i++)
{
networkFiles = + localDrive[i];
localFiles = + Environment.NewLine;
}

Please help

Nov 19 '05 #4
perfect :), just what i neeed.

thanks karl
"Karl Seguin" wrote:
You want += not =+

and why not just use

networkFiles = String.Join("\n", localDrive);

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"huzz" <hu**@discussions.microsoft.com> wrote in message
news:41**********************************@microsof t.com...
oops.. the code should be:

for(int i; i < localDrive.Length; i++)
{
networkFiles = + localDrive[i];
networkFiles = + Environment.NewLine;
}
"huzz" wrote:
I like to put all the values of an array into a single variable like:

networkFiles = "val 1
val 2
val 3
val 4
val 5";

Here is what i am doing, but getting error message:
Operator '+' cannot be applied to operand of type 'string'

string networkFiles;
networkFiles = "";

for(int i; i < localDrive.Length; i++)
{
networkFiles = + localDrive[i];
localFiles = + Environment.NewLine;
}

Please help


Nov 19 '05 #5

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

Similar topics

7
5132
by: richbl | last post by:
Hello all, I have a question about unserializing a single array element from a serialized array. Can this be done, or must I first unserialize the array, and then access the element? For...
58
10046
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
8
2094
by: Gactimus | last post by:
I made the program below. It outputs the smallest number in the array. What I would like to know is how do I output the array location. I am at a loss. For example, since the smallest number in...
16
41741
by: herbertF | last post by:
Hi guys, In a program (not my own) I encountered the declaration of a constant pointer to an array consisting of two other const pointers to arrays. Not quite sure why they do it so complicated,...
7
7373
by: simkn | last post by:
Hello, I'm writing a function that updates an array. That is, given an array, change each element. The trick is this: I can't change any elements until I've processed the entire array. For...
5
1461
by: Chris H | last post by:
Okay, I am trying to us a varialble with a list of number values as my data for an array, yet when I do this it doesnt return any values from the array, i was able to temporarily fix the proble by...
45
4761
by: VK | last post by:
(see the post by ASM in the original thread; can be seen at <http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/3716384d8bfa1b0b> as an option) As that is not in relevance to...
4
4327
by: IRC | last post by:
hey, i am pretty new on javascript as well as PHP, Hey, anyone can you help me, how to pass the javascript array value to php page......... i want to retrieve the values which are arrayed on...
37
2634
by: miken32 | last post by:
In PHP, if a function returns an array it's fairly common to capture its return values like this: <?php list($foo, $bar, $baz) = some_function_that_return_an_array(); ?> In Javascript, would...
33
7129
by: Adam Chapman | last post by:
Hi, Im trying to migrate from programming in Matlab over to C. Im trying to make a simple function to multiply one matrix by the other. I've realised that C can't determine the size of a 2d...
0
7349
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
7467
tracyyun
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...
0
5594
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
5022
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
4688
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
3177
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
1521
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 ...
1
746
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
399
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.