String errors

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?Ym9iYnk=?=

    #1

    String errors

    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(pa rams char[]) has some
    Invalid arguments.
    Even in intelligence I can't see split method.

    string[] myContents = ReadFileLines(p ath);
    for (int z = 0; z < myContents.Leng th; z++)
    {
    string[] line = String.Split(my Contents[z],"\t");

  • Christof Nordiek

    #2
    Re: String errors

    "bobby" <bobby@discussi ons.microsoft.c omschrieb im Newsbeitrag
    news:D80949DD-3559-47B7-9F33-2A6503D8C843@mi crosoft.com...
    >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(pa rams char[]) has some
    Invalid arguments.
    Even in intelligence I can't see split method.
    >
    string[] myContents = ReadFileLines(p ath);
    for (int z = 0; z < myContents.Leng th; z++)
    {
    string[] line = String.Split(my Contents[z],"\t");
    >
    It should be:
    string[] line = myContents[z].Split('\t');

    Christof

    Comment

    • Guest's Avatar

      #3
      Re: String errors

      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.


      --
      Ged Moretta
      Founded in 1999, AppSense was a global leader in secure user environment management with more than 3,500 customers securing over 8 million endpoints.


      -----------------------------------------------------------------------
      This signature isn't automatic. I have to type it manually every time.


      "bobby" <bobby@discussi ons.microsoft.c omwrote in message
      news:D80949DD-3559-47B7-9F33-2A6503D8C843@mi crosoft.com...
      >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(pa rams char[]) has some
      Invalid arguments.
      Even in intelligence I can't see split method.
      >
      string[] myContents = ReadFileLines(p ath);
      for (int z = 0; z < myContents.Leng th; z++)
      {
      string[] line = String.Split(my Contents[z],"\t");
      >

      Comment

      Working...