Re: Simple String problem
Take the postion of : and Sex and Extract the inner text using the substring method. Then use ArrayList Collection object to store this values.Before adding these values to the array list,check whether the value exist in the array list using .Contains method of the ArrayList.If u want to some coding please do comeback :)
Re: Simple String problem
Dear aspnetprog,
As i think you split the string using String.Split function according to ":" then validate the string. for example,
Code:
string sfile = "Patient Name: GEORGE ABRAMS Sex:Male";
string[] splirt = sfile.Split(char.Parse(":"));
foreach(string s in splirt)
{
if (!s.Contains("Patient Name"))
{
if (s.Contains("Sex"))
{
string ss = s.Substring(0, s.IndexOf("Sex"));
Console.Write(ss);
}
else
{
Console.Write(s);
}
}
}
Thanks..
Re: Simple String problem
thanks Sekarm. that code works fine
But now in new file there should not be any repetitions like line 1 and 4 are the same. The output file should Not have same entry.
GEORGE ABRAMS male
John B RAMS Male
Sandy SA ABRAMS Male
GEORGE ABRAMS male
I dont want repetitions...any help
Re: Simple String problem
Dear aspnetprog,
As Danasegarane told you have add string file in Arraylist. Use ArrayList.Contains function you may check the current file is added or not. then you may not get repitation.
Thanks...
Re: Simple String problem
Thanks a lot. I will try thr arraylist.