Browsing 7239 questions and answers with Jon Skeet
You can do it using List<T>.ForEach: list.ForEach(Console.WriteLine); This employs a method group conversion to create an Action<int> to call Console.WriteLine(int) for each element of list. However, personally I would use... more 2/28/2016 1:46:19 PM
The simplest approach is just to subtract the literal 'a'... which will implicitly convert both your input letter and the 'a' to int: public int convert(char letter) { if (letter < 'a' || letter > 'z') { throw new... more 2/27/2016 12:15:08 PM
Yes, the simplest option would probably be: var nullIndexes = list.Select((value, index) => new { value, index }) .Where(pair => pair.value == null) .Select(pair => pair.index) ... more 2/27/2016 11:10:31 AM
Task.WhenAny is going to return a Task<Task<TResult>>: Awaiting the result of Task.WhenAny() will return the first task that completed Awaiting that task will return the results of the task, i.e. a TResult[]. You might find... more 2/27/2016 10:37:03 AM
In the first case, the compiler is already providing a backing field - it's just implicit (and it's given a name that you can't refer to in code). Note that there has to be a backing field in the generated code, as a property itself is... more 2/27/2016 9:39:52 AM
I suspect you're writing a portable class library or something like that - if you look at the list of supported platforms in StreamWriter(String) it's considerably smaller than the list of supported platforms in StreamWriter(Stream). I... more 2/27/2016 6:55:00 AM
If you need to cancel all the consumers independently, you need separate cancellation tokens - and thus separate cancellation token sources. var consumers = Enumerable .Range(0, 10) .Select(_ => new... more 2/26/2016 11:30:24 PM
Firstly, it's important to understand that what you've got isn't a time zone. It's a UTC offset (although the negation of what it would normally be...). A real time zone would need to indicate how that UTC offset varies over time (e.g. due... more 2/26/2016 11:51:28 AM
Well, you won't be able to use async in the initial call. That much is clear. But you can use a synchronous delegate which calls the function, and then captures the returned task to await it inside an async delegate: public static... more 2/25/2016 5:17:51 PM
Constructors are executed once. Methods can be executed multiple times. Assignments to final variables are only permitted once - it's as simple as that. (If they could be assigned different values after construction, they wouldn't be very... more 2/25/2016 11:18:54 AM