locked
problem of getting string chains in string[] : substring (aspx - c#) RRS feed

  • Question

  • User-458598543 posted

    hello,

    i've got a problem of method to get a part of strings chain in a string tab.

    the following code is :

    aspx:

    <div>
    <textarea id="ta_1" runat="server" style="width: 680px; height: 400px"></textarea>
    </div>

    c# :

    protected void string_ceesure_pays()
    {
    string [] string_extraction = File.ReadAllLines(@"C:\international.jobersplace.com\liste_pays_eetats-nations.txt");

    /* an extract of the string tab is the following :

    Pays;Français;ISO 2;ISO 3;ISO ON;
    Afghanistan;Afghanistan;AF;AFG;004;
    Aland Islands;Îles Aland;AX;ALA;248;
    Albania;Albanie;AL;ALB;008;

    the problem is that i want extract only the colum 3 as "ISO 2" and my method doesn't work.

    */

    foreach(var string_sub in string_extraction)
    {
    string_part2 = string_sub.Substring(int_found +3) + string_part2;
    }

    ta_1.Value = string_part2;

    }

    thanks you for your help.

    Thursday, February 25, 2021 9:05 AM

Answers

  • User-458598543 posted

    Finally after research, i found the solution. i had used the "split" method and it's ok.

    the following code is :

    foreach(var string_sub in string_extraction)
    {
    string[] subs = string_sub.Split(';');
    string_part2 = subs[2] + "," + string_part2;

    }

    ta_1.Value = string_part2;

    thanks you.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 25, 2021 9:48 AM