Monday, May 8, 2017

C# Refresher









https://app.pluralsight.com/library/courses/csharp-best-practices-collections-generics/table-of-contents


http://stackoverflow.com/questions/558304/can-anyone-explain-ienumerable-and-ienumerator-to-me

https://www.dotnetperls.com/parse

https://csharp.2000things.com/

https://csharp.2000things.com/2010/07/25/38-data-type-hierarchy/



  • String Interpolation
  • Extension Method

Async Await

When using async and await the compiler generates a state machine in the background.
Here's an example on which I hope I can explain some of the high-level details that are going on:
public async Task MyMethodAsync()
{
    Task<int> longRunningTask = LongRunningOperationAsync();
    // independent work which doesn't need the result of LongRunningOperationAsync can be done here

    //and now we call await on the task 
    int result = await longRunningTask;
    //use the result 
    Console.WriteLine(result);
}

public async Task<int> LongRunningOperationAsync() // assume we return an int from this long running operation 
{
    await Task.Delay(1000); //1 seconds delay
    return 1;
}