Resharper’s example code for explaining “Possible multiple enumeration of IEnumerable”

GetNames() returns an IEnumerable. So if you store that result: IEnumerable foo = GetNames(); Then every time you enumerate foo, the GetNames() method is called again (not literally, I can’t find a link that properly explains the details, but see IEnumerable.GetEnumerator()). Resharper sees this, and suggests you to store the result of enumerating GetNames() in … Read more

How do I generate a constructor from class fields using Visual Studio (and/or ReSharper)?

In Visual Studio 2015 Update3 I have this feature. Just by highlighting properties and then press Ctrl + . and then press Generate Constructor. For example, if you’ve highlighted two properties it will suggest you to create a constructor with two parameters and if you’ve selected three it will suggest one with three parameters and so on. … Read more

Is Int32.ToString() culture-specific?

The Operating System allows to change the negative sign for numbers. Control panel -> Language and regional settings -> Additional settings -> Negative sign So, current culture could have overridden the negative sign. In this case you need to respect the regional settings, this is the reason of the warning. You can also change the … Read more

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