Hi ,
I found one solution . Please find the below code.
string[] lines = System.IO.File.ReadAllLines(@"input.txt");
string fnString = "", keyStr = "";
ArrayList arLst = new ArrayList();
arLst.Add("Col1 Col2");
for (int i = 1; i < lines.Count(); i++)
{
fnString = ""; keyStr = "";
if (lines[i].Trim() != "")
{
string[] arrRow = lines[i].Split(' ');
for (int j = 1; j < lines.Count(); j++)
{
if (lines[j].Trim() != "")
{
string[] arrRow1 = lines[j].Split(' ');
keyStr = arrRow[0];
if (arrRow[0].Equals(arrRow1[0]))
{
fnString += arrRow1[1] + ";";
lines[j] = "";
}
}
}
if (fnString.EndsWith(";"))
fnString = fnString.Substring(0, fnString.Length - 1);
arLst.Add(keyStr + ' ' + fnString);
}
}
using (var streamWriter = new StreamWriter(@"output.txt"))
{
for (int i = 0; i < arLst.Count; i++)
{
streamWriter.WriteLine(arLst[i]);
}
streamWriter.Close();
}