473,604 Members | 2,481 Online
Bytes | Software Development & Data Engineering Community
+ 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, StringSplitOpti ons.None); //This part
works
string[] Sample = new string[Channel.Length];
string[] stringSeparator s = new String[] { "\t" };
foreach (string ArrayString in Channel)
{
int i = 0;
Sample[i] = ArrayString.Spl it(stringSepara tors,
StringSplitOpti ons.None);
i++;
}

Thanks
Mike
Mar 11 '08 #1
2 2170
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.Spl it(stringSepara tors,
StringSplitOpti ons.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.co mwrote:
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.Spl it(stringSepara tors,
StringSplitOpti ons.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
4890
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 with the following data : 1. Stijn Piot 58.12; 2. Kim Van Rooy 1.25; 3. Johnny Marcovich 2.37; 4. John Terlaeken (Bel) 1 ronde/tour; 5. Michael Bertrand 2.12;
7
11728
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
2891
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 newString = ",a,b,c,"; var treeArray = newString.split(/\,/i); alert(treeArray.length);
19
10906
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 empty strings in the resulting string array.
3
3223
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 database or a Disconnected ADO Recordset since this is just passing data along to be written into an XML file... I've figured out how to split the data line by line by doing a
3
9653
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... field1...field2...field3...
5
5866
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() = Microsoft.VisualBasic.Strings.Split(aLine, vbNewLine, -1, CompareMethod.Binary)
2
2185
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 = "field != value" result = s1.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries);
14
1716
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 illogically? Here's a test I just put together that splits on "&". The test strings are: "a&b" = (Correct!) I expect array length 2 and I get 2 "a&" = (Incorrect!) I expect array length 1 but I get 2 "a" = (Correct!) I expect array length 1 and...
0
7929
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,...
0
8419
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, 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...
0
8409
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 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...
1
8065
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8280
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 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...
1
5882
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 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...
0
5441
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3907
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...
0
3955
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.