Code Providers – Convert to Integer
The Convert to Integer code provider allows you to wrap an expression returning a non-integer value to Math.Ceiling, Math.Floor, or Math.Round. Consider the following code sample:
The Convert to Integer code provider allows you to wrap an expression returning a non-integer value to Math.Ceiling, Math.Floor, or Math.Round. Consider the following code sample:
This is just a quick overview list to organize a bunch of refactorings that deal with loops and blocks. Click the refactoring name to learn more about it.
This refactoring embeds a single statement into curly braces.
This refactoring combines several neighboring or nested using statements that cover variables of the same type into a single using statement.
Locking is essential in programs with multi-threading. It restricts code from being executed by more than one thread at the same time. The lock statement gets the exclusive monitor for an object and ensures that no other thread can access the object until the lock is released.
The lock statement automatically generates exception safe code, and in fact it is a syntactic shortcut for a call to the methods Monitor.Enter(obj) and Monitor.Exit(obj) with a try/finally block. However, if the thread is aborted after the lock is acquired but before entering the try block, the lock will not be released. Also, bear in mind that the Monitor.Enter() waits to acquire the lock forever which may introduce a possible deadlock condition.
As many of you know, the using statement is a good tool for managing types which will be accessing unmanaged resources. The using statement provides a simple and convenient syntax that ensures that objects that implement the IDisposable interface are correctly disposed.
If the object is not disposed, CodeRush highlights the undisposed variables with the “Undisposed local” code issue:
Auto-implemented properties enable you to quickly specify a property without having to write logic for the property accessors. The auto-property’s logic and the field serving as a backing store are automatically generated by the compiler. Such properties appeared in C# version 3.0 and Visual Basic version 10.0.