Click here to Skip to main content
15,889,281 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hy
I want to check that the current Username is available in that department or not Department_Id

How i Apply that in if else statement

C#
string Username = User.Identity.Name;   // Current Username
DataTable dt;
Employee_In_Department Depart_Class = new Employee_In_Department();
Depart_Class.Retrieve_Employee_In_Department_By_All(ref Connection_string, out dt);
List(byte) arr = new List(byte)();
for (int i = 0; i < dt.Rows.Count; i++)
{
   arr.Add(Convert.ToByte(dt.Rows[i]["Department_Id"])); // All Department Id in table
}

if (Username ==arr )
{

}
Posted
Updated 1-Apr-15 6:57am
v4
Comments
Arkadeep De 1-Apr-15 12:39pm    
Improve the question properly and whats the issue in checking two values?

1 solution

You can use Conditional Operator like &&,|| and !.This operator are helpful in complex expression.

if(age == 40 && name == "hitesh")
 
Share this answer
 
Comments
Gurpreet Arora Malhotra 1-Apr-15 12:48pm    
Hi Hitest In this Question Current Username is not fixed and department is also and its also possible one user has 2 department

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