Murali Kris

Murali Kris

  • 1.5k
  • 254
  • 48.1k

how to clear previous values during looping.

Nov 5 2018 11:10 PM
Hi,
 
using below code i can read datatable row value. when it loops 2nd row its printing 1st row values also, if it at 3rd possion(3rd row  posstion) it is printing 1st row data, 2nd row data and 3rd row data. 
 
how to get only current row vaues , how to clear previous values during looping.
 
foreach (DataRow row in dt.Rows)
{
char[] mychars = { ';' }; // it has to split if it find semicolon.
List<string> textn = new List<string>();
textn.Clear();
textn = new List<string>(new[] { row["Source-USER/GRP PERMISSIONS"].ToString() });
string combindedString = null;
combindedString = string.Join(Environment.NewLine, textn.ToArray());
string[] names = null;
names = combindedString.Split(mychars, StringSplitOptions.None);
foreach (var item in names)
{
MessageBox.Show(item.ToString());
}
}

Answers (2)