Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am adding string to a DB value and displaying so if i get a duplicate it should not display the same thing

C#
for (int i = 0; i < lstRecData.Count; i++)
{
    if (lstRecData[i].strRecDesc.ToUpper() != strContactVib && lstRecData[i].strRecPriority == "3")
    {
      lstRecData[i].strRecDesc = "Schedule Maintenance:" + lstRecData[i].strRecDesc;
    }
}



here once this "Schedule Maintenance:" + lstRecData[i].strRecDesc; is there i shouldn't execute the statement how can i achieve it?
Posted
Updated 15-Sep-14 19:24pm
v2
Comments
George Jonsson 16-Sep-14 1:35am    
Maybe you should rephrase your question. It is not clear what you want.
Use the 'Improve solution' widget.

Search the string as :

foreach(string item in myList)
{
  if(item.Contains(myString))
       return item;
}
 
Share this answer
 
C#
for (int i = 0; i < lstRecData.Count; i++)
{
    if (lstRecData[i].strRecDesc.ToUpper() != strContactVib && lstRecData[i].strRecPriority == "3")
    {
if (!lstRecData.Contains("Schedule Maintenance:" + lstRecData[i].strRecDesc"))
      lstRecData[i].strRecDesc = "Schedule Maintenance:" + lstRecData[i].strRecDesc;
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900