Rewriting Java code to c#
I am busy rewriting some code to c# but i have rub into some difficulty with the following piece.

     SearchControls ctls = new SearchControls();
       ctls.setReturningAttributes(attrIDs);
       ctls.setSearchScope(ctls.SUBTREE_SCOPE);
	   String searchBase ="";
	   
	   searchBase = "ou=Users,ou=ABSASAPHR,c=za";
		int count=0;
		int count2=0;
	   NamingEnumeration answer = ctx.search(searchBase, filter, ctls);
       while (answer.hasMore())
	   {
    	   count=count+1;
           SearchResult sr = (SearchResult)answer.next();          
           String dn = sr.getName();
           Attributes attrs = sr.getAttributes();
           String uid,cn,emp,empno;
		   		   try 
		   {
			 cn = attrs.get("cn").toString();
		   } catch (Exception err) 
		   {
			 cn = " ";
		   }
		  String cn1[]=cn.split(": ");
		  uid=cn1[1];
		   try 
		   {
			 emp = attrs.get("uid").toString();
		   } catch (Exception err) 
		   {
			 emp = " ";
		   }
		  String empno1[]=emp.split(": ");
		  empno=empno1[1];
		  boolean flag=false;
I presume a converter would not work and ihave a very basic understanding of java. Could any one please point me in the right direction.
Thanks
Rewriting Java code to c#
===

I am busy rewriting some code to c# but i have rub into some difficulty with the following piece.

     SearchControls ctls = new SearchControls();
       ctls.setReturningAttributes(attrIDs);
       ctls.setSearchScope(ctls.SUBTREE_SCOPE);
	   String searchBase ="";
	   
	   searchBase = "ou=Users,ou=ABSASAPHR,c=za";
		int count=0;
		int count2=0;
	   NamingEnumeration answer = ctx.search(searchBase, filter, ctls);
       while (answer.hasMore())
	   {
    	   count=count+1;
           SearchResult sr = (SearchResult)answer.next();          
           String dn = sr.getName();
           Attributes attrs = sr.getAttributes();
           String uid,cn,emp,empno;
		   		   try 
		   {
			 cn = attrs.get("cn").toString();
		   } catch (Exception err) 
		   {
			 cn = " ";
		   }
		  String cn1[]=cn.split(": ");
		  uid=cn1[1];
		   try 
		   {
			 emp = attrs.get("uid").toString();
		   } catch (Exception err) 
		   {
			 emp = " ";
		   }
		  String empno1[]=emp.split(": ");
		  empno=empno1[1];
		  boolean flag=false;
I presume a converter would not work and ihave a very basic understanding of java. Could any one please point me in the right direction.
Thanks