I have a foreach loop going that is adding e-mail address to an array. At the end I join the array and push it into a string.
I have an issue when someone in the database has a blank email address it messes up my logic. Can someone help me fix this?
TestGuy1:
TestGuy2: 2@2.com
TestGuy3: 3@3.com
With the above information it creates a 3 length array and then turns it into a string like so:
sEmailList "2@2.com,3@3.com," string
Code:
DataTable GetUserReportsToChain = objEmployee.GetUserReportsToChain(LoginID, ConfigurationManager.AppSettings.Get("Connection").ToString());
int RowCount = GetUserReportsToChain.Rows.Count;
string[] aEmailList = new string[RowCount];
int iCounter = 0;
foreach (DataRow rRow in GetUserReportsToChain.Rows)
{
if (rRow["usrEmailAddress"].ToString() != "")
{
aEmailList[iCounter] = rRow["usrEmailAddress"].ToString();
iCounter++;
//String email = rRow["usrEmailAddress"].ToString();
}
}
string sEmailList = String.Join(",", aEmailList);
Any idea how I can fix this when the database has a blank value for e-mail?
All in one