Solved

Convert VB.Net to C#

Posted on 2009-04-09
4
220 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Turn Insights Into Action

You’ve already invested in ITSM tools, chat applications, automation utilities, and more. Fortify these solutions with intelligent communications so you can drive business processes forward.

With xMatters, you'll never miss a beat.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

717 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