Solved

Convert VB.Net to C#

Posted on 2009-04-09
4
215 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
Comment Utility
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
Comment Utility
cmbSetupAddUserDomainUsers.Items.Add(sr.Properties["samaccountname"][0])
0
 
LVL 29

Expert Comment

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

Expert Comment

by:oobayly
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
C# Export DataGridView 4 37
Hovering effect 9 28
Trouble with References... 5 21
Make a border less form movable 2 10
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

763 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

12 Experts available now in Live!

Get 1:1 Help Now