Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

New answers tagged

1

I'm going to start off by saying I didn't test this code. There might be some issues but I didn't setup EF and an In Memory Provider. First I would load all the types right away and cache them and do some filtering to make sure they have the two properties we care about. You didn't save what your class name is so I'm going with DropDownLookUp public ...


4

You basically always need to use brute force here. There is no other way. However, you can do it a bit more efficiently. You're redoing the whole summation in every step of the loop. You don't need to. You can compute the total with one subtraction and one addition in each step of the loop. Like this: static int birthday(List<int> s, int d, int m) { ...


2

Review Here's the method I came up with, but it feels inelegant and incomplete. Any improvements, especially ones that can leverage LINQ are welcome. You could write it more elegantly by using recursion for your pair members. if (pair.First is IEnumerable) { Flatten((root as Pair).First, list); } else if (pair.First is Pair) { list....


2

Review Don't trust parameters of public methods purely on their name orderedArray. I will address how to handle this further in this answer. private static string AddDashesBetweenConsecutiveNumbers(int[] orderedArray) { You mentioned but this code has some disadvantages, especially in readability of the LINQ expression We could create a ...


1

I've thought about a factory method, but that won't work because it can't be translated to SQL by the expression interpreter. Why don't you call (as suggested by t3chb0t) AsEnumerable() right before your factory method? You would perform the factory method in memory. var project = entities.Tickets .Where(p => p.ID == id) .AsEnumerable(...


0

I can't check this with a compiler right now but general idea is that you can benefit from IQueryable. Define method like this IQueryable<ListProject> SelectListProjects(IQueryable<Tickets> tickets) { return entities.Tickets .Where(p => p.vonProjekt == id) .Where(p => p.phaseID == 0) .OrderBy(p => p....


4

Let's start with the basics: names and namespaces. To me the following names have the following meanings: Deck: either the set of 52 cards (basically a wrapper around ISet<Card>), or, more likely, the cards which haven't yet been dealt (basically a wrapper around IList<Card>). In the latter case I'd expect it to have methods to deal from the ...


4

Performance Your code tests against all possible hand result kinds. Is this useful or could you abort whenever you get a match? Is performance an actual requirement anway? public HandResult GetHandResult(int playerID) { IEnumerable<Card> set = GetPlayerSet(playerID).OrderBy(x => x.Face); return new[] { ...


1

Here's a Linq approach that allows you to perform an analytical function on a collection, given a order by clause, and a predicate to determine whether the current item and the previous item (analytical lag) are in the same group. It can be extended to also take into account a partition, but that's out of scope to serve your purpose. This is a more ...


Top 50 recent answers are included