Sometime ago I wrote about the new feature in C# 6 which allow us to use String Interpolation instead of String.Format(). In C# 6 we also found a new cool operator: nameof. This new operator allows us to get in string the name of a variable, or a type or a member. If you think in exception handling scenarios or dynamic generation this is very useful.
So, let’s see this in action, with a sample console Project and a custom class.
In the Console Main(), the program Display the name of a couple of variables and also the name of a couple of operations (custom and system). The console Output is this one
– El Bruno, String Interpolation https://elbruno.com/2015/04/20/vs2015-string-interpolation-vs-string-format-your-team-will-love-you/
– MSDN nameof, https://msdn.microsoft.com/en-us/library/dn986596.aspx
Saludos @ Madrid