473,480 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Trying to split an array on a tab

AMP
Hello,
I am trying to split an Array into another array. Each value in the
array has tab delimited strings.
I am getting:
Cannot implicitly convert type 'string[]' to 'string'
I am trying this:
string[] lineSeparators = new String[]{"\r\n"};
string[] Channel =
FileName.Split(lineSeparators,StringSplitOptions.N one); //This part
works
string[] Sample = new string[Channel.Length];
string[] stringSeparators = new String[] { "\t" };
foreach (string ArrayString in Channel)
{
int i = 0;
Sample[i] = ArrayString.Split(stringSeparators,
StringSplitOptions.None);
i++;
}

Thanks
Mike
Mar 11 '08 #1
2 2150
On Mar 11, 4:32 pm, AMP <ampel...@gmail.comwrote:
I am trying to split an Array into another array. Each value in the
array has tab delimited strings.
I am getting:
Cannot implicitly convert type 'string[]' to 'string'
And it's right. You've got

string[] Sample

which means that every element of Sample is a string.

You're then trying:
Sample[i] = ArrayString.Split(stringSeparators,
StringSplitOptions.None);

(and then reinitializing i next time round the loop, by the way)

string.Split returns an array of strings, not a single string - so you
quite possibly want

string[][] Sample = new string[Channel.Length][];

However, I suspect there's a rather better way of doing this. Could
you give an example of the input you've got, and the output you want?

Jon
Mar 11 '08 #2
AMP
On Mar 11, 12:38*pm, "Jon Skeet [C# MVP]" <sk...@pobox.comwrote:
On Mar 11, 4:32 pm, AMP <ampel...@gmail.comwrote:
I am trying to split an Array into another array. Each value in the
array has tab delimited strings.
I am getting:
Cannot implicitly convert type 'string[]' to 'string'

And it's right. You've got

string[] Sample

which means that every element of Sample is a string.

You're then trying:
Sample[i] = ArrayString.Split(stringSeparators,
StringSplitOptions.None);

(and then reinitializing i next time round the loop, by the way)

string.Split returns an array of strings, not a single string - so you
quite possibly want

string[][] Sample = new string[Channel.Length][];

However, I suspect there's a rather better way of doing this. Could
you give an example of the input you've got, and the output you want?

Jon
Jon,
Its one long string.
There are \r\n's at the end of rows and and \t's at the end of
datapoints
I want each row to be an Array by itself.

3 1466 1462 1531 1465 1279 1490 1454 1441 1457 1453 1460 1459 1321
1457 1443 1443 55
75 1471 1469 1194 1467 2170 1491 1453 1442 1457 1455 1459 1460 2193
1459 1443 1443 127
148 1471 1472 1481 1463 1780 1490 1453 1442 1458 1455 1459 1459 1759
1455 1444 1442 200
220 1473 1470 1482 1465 843 1491 1453 1441 1458 1454 1459 1459 321
1455 1443 1443 272
293 1473 1480 1461 1465 1375 1486 1453 1443 1458 1455 1460 1459 1208
1457 1443 1442 344
365 1471 1472 1454 1463 1442 1490 1260 1446 1457 1456 1461 1460 1364
1457 1444 1441 417
438 1469 1459 1450 1460 1449 1489 2117 1444 1375 1455 1461 1459 1419
1458 1444 1442 489
510 1469 1463 1448 1460 1451 1491 1680 1443 2545 1463 1459 1460 1437
1459 1445 1442 562
582 1470 1466 1447 1459 1451 1489 1165 1435 1716 1454 1459 1460 1444
1458 1445 1443 634
655 1471 1478 1447 1461 1451 1489 1361 1440 483 1459 1459 1460 1447
1457 1444 1442 707
727 1469 1461 1447 1460 1452 1489 1420 1441 1004 1452 1458 1460 1448
1457 1443 1443 779
800 1468 1465 1447 1460 1453 1491 1441 1443 1313 1455 1460 1460 1448
1457 1444 1443 851
872 1462 1467 1447 1461 1454 1490 1449 1440 1407 1457 1461 1459 1448
1457 1443 1442 924
944 1462 1467 1446 1462 1454 1491 1451 1442 1439 1455 1460 1459 1449
1456 1443 1441 996

Thanks
mike
Mar 11 '08 #3

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

Similar topics

2
4885
by: nieuws | last post by:
Hi, I was trying to do the following. It's my first php "project", so it's quiet logic that i have some problems. Perhaps the php community might help. It's about this : I have a txt file...
7
11721
by: brianshields | last post by:
array("a", "b", "c", "d", "e"); I want to now be able to load "b" into a variable ($var) then print it out print $var thanks!
1
2880
by: jhcorey | last post by:
I don't know where the actual issue is, but hopefully someone can explain. The following displays "5" in FireFox, but "3" in IE: <script type="text/javascript" language="javascript"> var...
19
10890
by: David Logan | last post by:
We need an additional function in the String class. We need the ability to suppress empty fields, so that we can more effectively parse. Right now, multiple whitespace characters create multiple...
3
3215
by: Jan Hanssen | last post by:
Hi! I have a list of data in a textfile which is tab delimited. Each line is seperated by a VbCrLf. I want to collect this data in a multidimensional string array. I do not wish to use a...
3
9641
by: Ben | last post by:
Hi I am creating a dynamic function to return a two dimensional array from a delimeted string. The delimited string is like: field1...field2...field3... field1...field2...field3......
5
5846
by: kurt sune | last post by:
The code: Dim aLine As String = "cat" & vbNewLine & "dog" & vbNewLine & "fox" & vbNewLine Dim csvColumns1 As String() = aLine.Split(vbNewLine, vbCr, vbLf) Dim csvColumns2 As String() =...
2
2168
by: Digital Fart | last post by:
following code would split a string "a != b" into 2 strings "a" and "b". but is there a way to know what seperator was used? string charSeparators = { "=", ">=", "<=" , "!=" }; string s1 =...
14
1703
by: Stevo | last post by:
If you split a string into an array using the split method, it's not working the way I'd expect it to. That doesn't mean it's wrong of course, but would anyone else agree it's working somewhat...
0
7037
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
7034
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,...
1
6732
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6886
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
5324
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
4768
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
2990
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
2976
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
174
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.