Nothing to see...

A simple blog about all things in the world that is ridikulouse.

Monday, July 20, 2015

String Interpolation

String Interpolation is an interesting method of being able to access properties directly within a string. Once upon a time in order to include properties into a string you would have to do something like this : int age = 16; string mystr = "My age is" + age.ToString(); Essentially a string concatenation and then returning other types as a string. Then we had string.Format which I thought it was fantastic with the autoconversion of types to string - so we had something like this: string.Format("My age is {0}", age); Now, this was very handy...

Null Conditional Operators

I cannot count the number of times that I've faced exception caused by running into a null. This then leads to code using the if{} blocks or using the short hand "?" on almost all of your variables. In C# 6.0 specification a null conditional operator. The null conditional operator allows you to check for the instance of a null and replace a returned value or to return a value. For example : If you have a simple class such as a Person : public class person { public string Name {get;set;} public int Age {get; set;} } and you instantiate...