Does not work else statement. Please help me.
int countArmyNC = 0;
foreach (DataGridViewRow row in dataGridView1APen.Rows)
{
if (row.Cells[4].Value.ToString() == "‡mbv evwnbx (bb KwgkÛ)")
{
countArmyNC++;
}
else
{
countArmyNC = "";
}
}
Tapan PatelRank #614 · 3.9K reputationPosted Sep 1, 2017, 10:26 AM EDT
Tapan PatelRank #614 · 3.9K reputationPosted Sep 1, 2017, 10:37 AM EDT
Ankit SharmaRank #141 · 16.1K reputationPosted Sep 1, 2017, 10:26 AM EDT
Shovan SahaRank #4,546 · 338 reputationPosted Sep 1, 2017, 10:31 AM EDT
Ankit SharmaRank #141 · 16.1K reputationPosted Sep 1, 2017, 10:45 AM EDT
Hamid KhanRank #424 · 5.9K reputationPosted Sep 4, 2017, 2:13 AM EDT
Manikandan MurugesanRank #300 · 8.4K reputationPosted Sep 4, 2017, 5:03 PM EDT
or better yet:
Also, since
Int32.TryParsereturns aboolyou can use its return value to make decisions about the results of the parsing attempt:If you are curious, the difference between
The TryParse method is like the Parse method, except the TryParse method does not throw an exception if the conversion fails. It eliminates the need to use exception handling to test for a FormatException in the event that s is invalid and cannot be successfully parsed.ParseandTryParseis best summed up like this:Hassan Uddin MughalRank #2,508 · 560 reputationPosted Sep 1, 2017, 9:27 PM EDT
Puneet KankarRank #446 · 5.6K reputationPosted Sep 2, 2017, 12:51 AM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts