filtering in string[] in c#.net?

Posted by Divs99 under C# on 8/20/2012 | Points: 10 | Views : 1515 | Status : [Member] | Replies : 2
i have to filter Userid's in string[] in c#.net?

string[] AllGaidUsers = Roles.GetUsersInRole(AdminGroup);
string ConfigUsers= ConfigurationManager.AppSettings.Get("UserId").ToString();
List<String> LstConfigUsers= new List<String>(ConfigUsers.Split(','));

now i have to check LstConfigUsers are exist in AllGaidUsers ?

how to filter in string[] AllGaidUsers whether LstConfigUsers are exist or not?




Responses

Posted by: Nadh123 on: 8/21/2012 [Member] Starter | Points: 25

Up
0
Down
I hope this is help for u
int maincount=0;
string strname = "mahi,ram,ramu,chandu,nadh";//this is database users
string strname1 = "mahi,nadh";//this is web.config users
string[] strfilter1 = strname.Split(',');
string[] strfilter2 = strname1.Split(',');
int count1 =Convert.ToInt32(strfilter1.Length);
int count2 = Convert.ToInt32(strfilter2.Length);
for(int i=0;i<strfilter1.Length;i++)
{
for (int j = 0; j < strfilter2.Length; j++)
{
if (strfilter1[i].ToString().ToUpper() == strfilter2[j].ToString().ToUpper())
{
maincount++;
}
}
}
if (maincount == count2)
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "msg", "alert('users are existed');", true);
else
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "msg", "alert('users are not existed');", true);

Mahendra
91-9908699686

Divs99, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: tapangupta-17555 on: 8/21/2012 [Member] Starter | Points: 25

Up
0
Down
if(strname .IndexOfAny(strname1 ) >= 0)
{
//success code
}

TAPAN

Divs99, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response