String errors

G

Guest

I have the following code and I am trying to read tab dilemited file. But it
gives me the following error
The best overload method match for String.Split(params char[]) has some
Invalid arguments.
Even in intelligence I can't see split method.

string[] myContents = ReadFileLines(path);
for (int z = 0; z < myContents.Length; z++)
{
string[] line = String.Split(myContents[z],"\t");
 
G

Guest

Split is not a static function.
What you should be doing is :

string[] line = myContents[z].Split('\t');

Note the single quotes around the \t. This indicates a char, rather than a
string.
 
C

Christof Nordiek

bobby said:
I have the following code and I am trying to read tab dilemited file. But
it
gives me the following error
The best overload method match for String.Split(params char[]) has some
Invalid arguments.
Even in intelligence I can't see split method.

string[] myContents = ReadFileLines(path);
for (int z = 0; z < myContents.Length; z++)
{
string[] line = String.Split(myContents[z],"\t");
It should be:
string[] line = myContents[z].Split('\t');

Christof
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top