Hi all i wrote the following code, what i am doing is i would like to use Switch case for my dictionary that exists but i am getting an error as
Can not implicitly convert string to bool
My code is as follows
List<string> lst = new List<string>();
lst.Add("Delete");
lst.Add("Reports");
lst.Add("Customer");
Dictionary<int, string> d = new Dictionary<int, string>();
d.Add(1, "Delete");
d.Add(2, "Reports");
foreach (string i in lst)
{
if (d.ContainsValue(i))
{
switch (d.ContainsValue(i))
{
case "Delete": // Here i would like to compare my value from dictionary
//link1.NavigateUrl = "Reports.aspx";
HyperLink1.NavigateUrl = "Delete.aspx";
break;
}
}
else
{
HyperLink2.Attributes["OnClick"] = "alert('Not a Valid User to Perform this operation'); return false";
}
}
returns boolean. When you do this:
You try to compare the bool with a string, so it fails. You need to do this: