popcorn
Delegate function with params
Hello, is it possible to somehow have "named" parameters in the delegate function?
Right now I have:
But that way you have to remember that the first argument is the actual number and the second argument is the expected value for example (In this case it doesn't matter, but let's say we have 3+ args..)
My question is:
Is it possible to have the usage like this somehow? Or using some other approach?
21 replies
Fluent Syntax - generic methods
Hi, I have a structure as follows:
and I want to be able to do :
So the rule is that the method .PlacedIn(canvas) must be either last to be called or must be followed by .At().
And .PlacedIn(stackPanel) can be anywhere and followed by any method.
The second problem I solved quite easily by:
But I'm not sure about the .PlacedIn(canvas). I think it should return some other type than the generic
T where : Control
but then the information about the type is lost and I don't know how to return the proper type (Label, Image, ...) In the .At() method afterwards.
How can I do this?29 replies
❔ query all items that match both properties.
I have a list of tuples as:
And I want to retrieve all items that match the int to score and string to PlayerName.
How can I do that using LINQ?
I don't want all the possible combinations of pair values.
19 replies
❔ Find values which are not present in hashsets
I have multiple hashsets of integers and one "main". I want to find all values from "main" hashset which are not present in some of the other hashets, what's the easiest/best way to do this?
a) Combine all the other hashsets into one and then do like
b) Do it one by one
c) Some other way?
3 replies
❔ Dynamic programming
Hello, I have a task, where I need to find the least keystrokes required to print a word.
I have a table sized X*Y filled with letters that can repeat
and I have a string
s
that can contain letters which are not in the table and should be skipped.
We cannot move diagonally in the table.
We always start at the left top corner.
How do I solve this using dynamic programming?
I have created a Dict where each letter gets List of positions it is in the table. But then I don't know how to look ahead.
Let's say we have table:
and string = ABCDEFA
Then when choosing F from E, how do I choose the middle one because it is closer to the next character (A) and not the right lower F12 replies
Keep Model instances without RelatedModel in query
Hi, how do I keep records that do not have related model value in my query?
I have a query like:
And all
MyModel
instances that do not have the RelatedModel
will be excluded in that query. How can I include them and just let the value be null?1 replies