Inserting string value into string[]

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hameeduddinasim
    New Member
    • Aug 2007
    • 13

    #1

    Inserting string value into string[]

    Hi

    I am trying to get the value from string into string[]

    it is working fine in VB.Net but i facing problem in C#

    VB Code

    Dim COABANKS() As String
    Dim SR3 As StreamReader = File.OpenText(p ath)
    Dim linestring As String
    linestring = SR3.ReadLine()
    COABANKS = linestring.Spli t(",")

    The above code is working fine

    C# Code

    string[] COABANKS;
    StreamReader SR3 = File.OpenText(p ath);
    string linestring;
    linestring = SR3.ReadLine();
    COABANKS = linestring.Spli t(",");

    Problem with C# code

    Kindly help me
    Thanks
  • Assam
    New Member
    • Aug 2007
    • 4

    #2
    Please replace double quotes with single quotes :) and the code would work fine. Actually split method takes character which is represented by ' ,' and when you give in double quotes it acts as string

    string[] COABANKS;
    StreamReader SR3 = File.OpenText(p ath);
    string linestring;
    linestring = SR3.ReadLine();
    COABANKS = linestring.Spli t(',');//Remove double quotes and then try

    Comment

    Working...