Last post Feb 25, 2021 09:48 AM by Rednuts72
Member
62 Points
233 Posts
Feb 25, 2021 09:05 AM|Rednuts72|LINK
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.
Feb 25, 2021 09:48 AM|Rednuts72|LINK
Finally after research, i found the solution. i had used the "split" method and it's ok.
foreach(var string_sub in string_extraction) { string[] subs = string_sub.Split(';'); string_part2 = subs[2] + "," + string_part2;
thanks you.
Member
62 Points
233 Posts
problem of getting string chains in string[] : substring (aspx - c#)
Feb 25, 2021 09:05 AM|Rednuts72|LINK
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.
Member
62 Points
233 Posts
Re: problem of getting string chains in string[] : substring (aspx - c#)
Feb 25, 2021 09:48 AM|Rednuts72|LINK
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.