Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
C# is a multi-paradigm, managed, garbage-collected, object-oriented programming language created by Microsoft in conjunction with the .NET platform. Use this tag for questions related to C#. In case a specific version of the framework is used, you could also include that tag; for instance .net-2.0.
0
votes
Simple foreach adding to a list
Considering the LINQ generated from refactoring this code, I think cleaning this up might require more effort than just using LINQ.
For example, you're assigning the item directly to the model, but …
1
vote
Dynamic, generic property "assignator"
I'll say it at the risk of sounding harsh--I believe the pattern of using strings and objects as generic "value-holders" but then pushing them into "generic" methods with string/object type parameters …
5
votes
Refactor foreach loops
I know this question has been answered, but I feel like this is a perfect case for the SequenceEqual method. Rather than having to handle the 2 equalitycomparers in the same layer you can change your …
3
votes
Create an instance (view) given its dependency (view model)
A ViewModel should not be convertible to a View, it should be bound to it. The View should have a ViewModel property. You should not have child Views for child ViewModels. Instead, you should have one …
1
vote
2
answers
177
views
Seemingly redundant conditionals...or not?
I'm working on some code that has the following pattern of conditionals inside it. It doesn't look great, but it doesn't look terrible.
Please, shed some light on the underlying reason this is not p …
1
vote
Accepted
Returning a cached contact by ID
It's debatable on which is more readable. I've worked in places where the common opinion is that an explicit else is more readable, and I've worked in places that consider the terser the code, the bet …
22
votes
Automapper - Mapping a nested collection to a list
When dealing with collections, the trick is always to set up a mapping of the items in the collections and never (well, I've never seen a case that needed) a mapping from one collection to another. Th …
1
vote
Validation for DTO using DataAnnotations
Not bad, but I'm not too fond of how the Validate instance method is just a call to a Validator static class passing in this. Just call the static method directly. If you're worried about the duplicat …
2
votes
Using an IEnumerator without a foreach loop in order to simulate a state machine
Your code is probably not working like you think it's working. I'd bet it works the same as code that just returns booleans directly.
Consider the fact that you're creating a new enumerator every ti …
4
votes
Accepted
Async insecurities
It would help to see how the UI is calling this because then we can see if UI blocking concerns are mitigated, but since you might get scolded for changing your question now that I've answered, I'm go …
0
votes
Suggestion for a lot of chained Task
You may not be able to get away from chaining a ton of ContinueWith invocations together. However, you might be able to create a builder class with methods that you pass parameters to so you don't hav …
1
vote
Are private extension methods a bad thing to use?
The smell here should not be whether it's private, but rather an extension method called in an extension method.
You might not even need the first two methods to be extension methods. If a fluent syn …
3
votes
First time trying async
Good code for a simple example of async. The real power of async/await comes into play when you have to make service calls, query a database, or you have several things happening at the same time. I t …
2
votes
Photo gallery user control
You really just need an IEnumerable of strings and not images. You could probably directly bind the results of the GetFiles method!!
Also I don't really see a need to break the method out of Page_Lo …
4
votes
Moving business logic towards the domain object as a design pattern
First, I would like to say thank you for asking this question, because this is the type of situation that average enterprise devs face every day and being able to recognize that something doesn't "fee …