.NET Garbage collector does almost all clean up activity for your objects. But unmanaged resources (example: Windows API created objects, File, Database connection objects, COM objects, etc.) are outside the scope of .NET Framework. We have to explicitly clean our resources. The problem with finalize is that garbage collection has to make two rounds in order to remove objects which have finalize methods since objects have to be placed in finalization queue in first round and later in next round of ......
The ref keyword tells the compiler that the object will be initialized before entering into the function, while out keyword tells the compiler that the object will be initialized inside the function.ref is two-ways, out is out-only ......
//Both are evaluatedif (_firstCondition =="" & _secondCondition == ""){ //Some code } // The second condition is evaluated only if the first is trueif (_firstCondition =="" && _secondCondition == ""){ //Some code } ......
Array Vs. ListDevelopers use arrays when their collection has a fixed length, and lists when they do notIt is always more efficient to use arrays over lists whenever possible.Underneath the hood most collections use arrays in their implementation, but it is still better to default to using an array. If the case arises in development that requires a variable size collection, List would be a good choice.List Vs. ArrayListUnlike List<T>, ArrayList is not a generic collection which means it stores ......
STRING ITERATIONC# allows the characters of a string to be iterated by using a “foreach” or a simple index access within a traditional “for”In this specific case, it is much more efficient to use a traditional “for” loop for iterating over a stringOne main reason for this is due to the fact that the JIT compiler can optimize “for” loops to remove bounds checking and other operations (it cannot do this with “foreach”).Using StringBuilder ClassC# Strings are immutable objects underneath the hood, so ......
Using the “static” keyword Static classes can only contain static members and cannot be instantiated. So using the static keyword will make your code a bit faster since no object creation is involved.Static methods can be accessed without an instance of the class being created.Static fields are shared across all instances of that class.In-short, they are all loaded once into memory and do not require instance resolution at run-time, which reduces the amount of instructions needed to call the method.Static ......
Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 Unit Testing Protected Methods You are responsible for unit testing your Protected methods just like the Public ones. The suggested guidance for how to do so is to create a fake class in your unit test that inherits from the class you are testing. Then in this new class, create public methods that expose the protected members of the base class. You can now use this fake child class in your tests.Unit Testing Abstract Classes ......