C#6.0 string interpolation localization

An interpolated string evaluates the block between the curly braces as a C# expression (e.g. {expression}, {1 + 1}, {person.FirstName}). This means that the expressions in an interpolated string must reference names in the current context. For example this statement will not compile: var nameFormat = $”My name is {name}”; // Cannot use *name* // … Read more

null conditional operator not working with nullable types?

Okay, I have done some thinking and testing. This is what happens: int value = nullableInt?.Value; Gives this error message when compiling: Type ‘int’ does not contain a definition for `Value’ That means that ? ‘converts’ the int? into the actual int value. This is effectively the same as: int value = nullableInt ?? default(int); … Read more

How are null values in C# string interpolation handled?

That’s just the same as string.Format(“Value is {0}”, someValue) which will check for a null reference and replace it with an empty string. It will however throw an exception if you actually pass null like this string.Format(“Value is {0}”, null). However in the case of $”Value is {null}” that null is set to an argument … Read more

Where Can I Find the C# Language Specification 6.0? [closed]

At time of writing (May 2016) Microsoft hasn’t yet finished updating the spec for C#6. In the meantime, I put up Microsoft’s latest current draft of the C#6 spec here: https://github.com/ljw1004/csharpspec/blob/gh-pages/README.md This current draft is almost finished, save for a few remaining TODO comments and checking. (This version has been converted into github+markdown, but it … Read more

Await in catch block

Update: C# 6.0 supports await in catch Old Answer: You can rewrite that code to move the await from the catch block using a flag: WebClient wc = new WebClient(); string result = null; bool downloadSucceeded; try { result = await wc.DownloadStringTaskAsync( new Uri( “http://badurl” ) ); downloadSucceeded = true; } catch { downloadSucceeded = … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)