Click here to Skip to main content
15,909,242 members
Home / Discussions / C#
   

C#

 
AnswerRe: Updating an access database table using C# Pin
Richard MacCutchan27-Oct-11 0:32
mveRichard MacCutchan27-Oct-11 0:32 
AnswerRe: Updating an access database table using C# Pin
BobJanova27-Oct-11 3:05
BobJanova27-Oct-11 3:05 
AnswerRe: Updating an access database table using C# Pin
jschell27-Oct-11 8:35
jschell27-Oct-11 8:35 
Question"Linked open data" in C# ASP.Net Pin
shanNSK26-Oct-11 20:49
shanNSK26-Oct-11 20:49 
AnswerRe: How to Convert URL to URI in rdf format? Pin
OriginalGriff26-Oct-11 22:00
mveOriginalGriff26-Oct-11 22:00 
QuestionC# access setting file Pin
sc steinhayse26-Oct-11 5:46
sc steinhayse26-Oct-11 5:46 
AnswerRe: C# access setting file Pin
Richard MacCutchan26-Oct-11 6:23
mveRichard MacCutchan26-Oct-11 6:23 
QuestionPreferred style Pin
Reiss26-Oct-11 5:24
professionalReiss26-Oct-11 5:24 
I have written the following

C#
List<Project> UserProjects = ...

string domain = cbxDomain.SelectedValue.ToString();
HashSet<string> itemsToShow = new HashSet<string>(); // See annotation 0


And I was wondering which of the two snippets below people prefer

A) Use a Predicate
C#
foreach (Project p in UserProjects.FindAll(delegate(Project x){return x.DomainName.Equals(domain);}))
{
    itemsToShow.Add(p.ProjectName);
}

Or

B) Nested if
C#
foreach (Project p in UserProjects)
{
    if (p.DomainName.Equals(domain))
    {
        itemsToShow.Add(p.ProjectName);
    }
}


0If you haven't used HashSet before, it is basically a List that sort of behaves like a Dictionary in that doesn't allow duplicates, but doesn't throw an exception if you try and add a duplicate. (I know that's an over simplification, - see MSDN[^] for full description)
GeneralRe: Preferred style Pin
harold aptroot26-Oct-11 5:37
harold aptroot26-Oct-11 5:37 
AnswerRe: Preferred style Pin
Paul Conrad26-Oct-11 5:42
professionalPaul Conrad26-Oct-11 5:42 
AnswerRe: Preferred style Pin
PIEBALDconsult26-Oct-11 6:29
mvePIEBALDconsult26-Oct-11 6:29 
AnswerRe: Preferred style Pin
Luc Pattyn26-Oct-11 6:31
sitebuilderLuc Pattyn26-Oct-11 6:31 
AnswerRe: Preferred style Pin
SledgeHammer0126-Oct-11 8:42
SledgeHammer0126-Oct-11 8:42 
GeneralRe: Preferred style Pin
harold aptroot26-Oct-11 9:09
harold aptroot26-Oct-11 9:09 
GeneralRe: Preferred style Pin
SledgeHammer0126-Oct-11 9:24
SledgeHammer0126-Oct-11 9:24 
AnswerRe: Preferred style Pin
BobJanova26-Oct-11 22:39
BobJanova26-Oct-11 22:39 
AnswerCheers Pin
Reiss27-Oct-11 22:02
professionalReiss27-Oct-11 22:02 
QuestionHandling Usercontrol with menu items in C# Pin
Hammad Rasheed25-Oct-11 23:36
Hammad Rasheed25-Oct-11 23:36 
AnswerRe: Handling Usercontrol with menu items in C# Pin
V.26-Oct-11 1:16
professionalV.26-Oct-11 1:16 
AnswerRe: Handling Usercontrol with menu items in C# Pin
PIEBALDconsult26-Oct-11 2:33
mvePIEBALDconsult26-Oct-11 2:33 
QuestionRe: Handling Usercontrol with menu items in C# Pin
Luc Pattyn26-Oct-11 4:16
sitebuilderLuc Pattyn26-Oct-11 4:16 
AnswerRe: Handling Usercontrol with menu items in C# Pin
PIEBALDconsult26-Oct-11 14:50
mvePIEBALDconsult26-Oct-11 14:50 
AnswerFlag: Repost of QA question: Re: Handling Usercontrol with menu items in C# Pin
BillWoodruff27-Oct-11 21:05
professionalBillWoodruff27-Oct-11 21:05 
QuestionInsert image on ricktextbox Pin
Chu Van Dat25-Oct-11 15:56
Chu Van Dat25-Oct-11 15:56 
AnswerRe: Insert image on ricktextbox Pin
Luc Pattyn25-Oct-11 16:24
sitebuilderLuc Pattyn25-Oct-11 16:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.