ReSharper and var [duplicate]

Resharper is primarily concerned with helping you refactor code, and the var keyword generally makes refactoring easier. For example, if the return values of any of those functions ever change to a compatibile type, you don’t have to change any of this code. It’s therefore now a little easier to refactor your tabCaseNotes type, for … Read more

Can we define implicit conversions of enums in c#?

There is a solution. Consider the following: public sealed class AccountStatus { public static readonly AccountStatus Open = new AccountStatus(1); public static readonly AccountStatus Closed = new AccountStatus(2); public static readonly SortedList<byte, AccountStatus> Values = new SortedList<byte, AccountStatus>(); private readonly byte Value; private AccountStatus(byte value) { this.Value = value; Values.Add(value, this); } public static implicit … Read more

Why do members of a static class need to be declared as static? Why isn’t it just implicit?

I get asked questions like this all the time. Basically the question boils down to “when a fact about a declared member can be deduced by the compiler should the explicit declaration of that fact be (1) required, (2) optional, or (3) forbidden?” There’s no one easy answer. Each one has to be taken on … Read more