Essential C# language features

Some interesting features of C# 6

Automatically implemented properties

Object initializer

Caller information (CallerFilePathAttribute, CallerLineNumberAttribute, CallerMemberNameAttribute)

Collection initializer

Extension Methods

Lambda Expressions

Var keyword

Anonymous types

LINQ

Async and Await

Expression bodied methods like CalcMonthlyWage(int dailyWage) => dailyWage * 30

Conditional access /Null propogation / Elvis (?.)

Auto-property initializers (no need for private set)

Primary constructor (adding constructor params at class lvl)

Declaring OUT param in method call (rather than separately)

Await can be called in catch/finally block, allowing async exception handling

Putting static class names in USING statements

String interpolation ({someval})

Exception filters – major new feature, taking advantage of existing CLR feature.  Syntactic sugar of allowing catch (Exception e) when (e.Code == 42).  But not simply syntactic sugar, it does not unwind the stack (which is how we lose state info on method that rethrew the exception).  If you use throw, vs throw ex; the stack is not unwould.  You can actually call a method as long as it returns a boolean

Posted in Uncategorized | Tagged , | Leave a comment

Critical elements of DI container

Dependency chain resolution – if requested component has its own dependencies, those too will get resolved.

Object lifecycle management – selecting whether the DI contain should return a singleton, transient (new instance each time), instance-per-thread, instance-per-HTTP-request, instance-from-pool, etc

Configuration of constructor params – handling of other parameters in interface constructor, such as strings that require a value to be set.

Posted in Dependency Injection, Uncategorized | Tagged , , , | Leave a comment