Solved

Convert VB.Net to C#

Posted on 2009-04-09
4
216 Views
Last Modified: 2013-12-17
Hi folks

Can anybody help me work out what the following would be in C#?  Have tried the usual online converting tools but don't seem to be giving me working code:
 For Each sr As SearchResult In src
                cmbSetupAddUserDomainUsers.Items.Add(sr.Properties.Item("samaccountname").Item(0))
                domainUsers.Add(sr.Properties.Item("samaccountname").Item(0), sr)
            Next

src is a SearchResultCollection.  And C# doesn't have a Properties.Item, I tried PropertyNames and Values but they didn't work (must be doing it wrong)
0
Comment
Question by:angus_young_acdc
  • 2
4 Comments
 
LVL 22

Expert Comment

by:p_davis
ID: 24107270
i am not familiar with that class
but is this what you are trying to accomplish?

http://msdn.microsoft.com/en-us/library/system.directoryservices.searchresult.properties(VS.71).aspx
0
 
LVL 29

Accepted Solution

by:
Gautham Janardhan earned 500 total points
ID: 24107279
cmbSetupAddUserDomainUsers.Items.Add(sr.Properties["samaccountname"][0])
0
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 24107290
domainUsers.Add(sr.Properties["samaccountname"][0], sr)
0
 
LVL 15

Expert Comment

by:oobayly
ID: 24107511
I use this site all the time for converting code to and from vb.net. Especially as I always do my code in c# and convert to vb.net when anwering vb.net questions :-)
http://www.developerfusion.com/tools/convert/csharp-to-vb/
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Loop not working 29 47
Unable to upgrade to .Net 4.6.2 on Server 2012r2 2 43
VB.net/WinForms: adjust Screen Resolution 6 41
C# Single Form 8 28
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now