What benefits does dictionary initializers add over collection initializers?

While you could initialize a dictionary with collection initializers, it’s quite cumbersome. Especially for something that’s supposed to be syntactic sugar. Dictionary initializers are much cleaner: var myDict = new Dictionary<int, string> { [1] = “Pankaj”, [2] = “Pankaj”, [3] = “Pankaj” }; More importantly these initializers aren’t just for dictionaries, they can be used … Read more

Using nameof to get name of current method

You can’t use nameof to achieve that, but how about this workaround: The below uses no direct reflection (just like nameof) and no explicit method name. Results.Add(GetCaller(), result); public static string GetCaller([CallerMemberName] string caller = null) { return caller; } GetCaller returns the name of any method that calls it.

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