Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

if string item is not in string array

Tags:

c#

I have a string array. I need to display buttons based on if the selected item is in the array. I need to know how to tell the program if "(array.NOT Contains("string"))". Please can anybody help me?? Thanks in advance

My code:

    List<string> activationids = new List<string>();
    foreach (ModuleActivation moduleactivation in activationid)
         activationids.Add(moduleactivation.ActivationID);

    string gvselectActID = GridView1.SelectedRow.Cells[1].Text;

    if (activationids.Contains(gvselectActID))
    {
      activateInsert.Visible = true;
      activateUpdate.Visible = false;
      deactivate.Visible = true;
    }
    else if (activationids."NOT" Contains(gvselectActID))
    {
      activateInsert.Visible = false;
      activateUpdate.Visible = true;
      deactivate.Visible = false;
    }
    else
    {
     activateInsert.Visible = false;
     activateUpdate.Visible = false;
     deactivate.Visible = false;
    }
  } 
like image 896
CSharpSuzie Avatar asked Aug 13 '10 08:08

CSharpSuzie


1 Answers

Change:

else if (activationids."NOT" Contains(gvselectActID)) 

to

else if (!activationids.Contains(gvselectActID)) 
like image 156
Neil Knight Avatar answered Nov 05 '22 11:11

Neil Knight