A shallow copy means the contents (each array element) contains references to the same object as the elements in the original array.
A deep copy (which neither of these methods performs) would create a new instance of each element’s object, resulting in a different, yet identical object. Basically it copies the source objects as well. So that there will be two different copies of the sources and objects.
|String.Compare||Compares the values of two strings. Returns an integer value|
|String.CompareOrdinal||Compares two strings without regard to local culture. Returns an integer value|
|String.CompareTo||Compares the current string object to another string. Returns an integer value|
|String.StartsWith||Determines whether a string begins with the string passed. Returns a Boolean value|
|String.EndsWith||Determines whether a string ends with the string passed. Returns a Boolean value|
|String.Equals||Determines whether two strings are the same. Returns a Boolean value|
|String.ReferenceEquals||Returns true if both objects point to the same location in memory|
- It is not possible to create instances of a static class using the new keyword.
- A class can be declared static, indicating that it contains only static members.
- If a class is declared as static then the variables and methods should compulsorily declared as static.
- Static classes are loaded automatically by the .NET Framework common language runtime (CLR) when the program or namespace containing the class is loaded.
- Static classes cannot contain a constructor, although it is still possible to declare a static constructor to assign initial values or set up some static state.
- The advantage of using a static class is that the compiler can check to make sure that no instance members are accidentally added.
- The compiler will guarantee that instances of this class cannot be created.
The main features of a static class are:
- They only contain static members.
- They cannot be instantiated.
- They are sealed.
- They cannot contain Instance Constructors
- A static method, field, property, or event is callable on a class even when no instance of the class has been created.
- Static members are often used to represent data or calculations that do not change in response to object state; for instance, a math library might contain static methods for calculating sine and cosine.
- Static class members are declared using the STATIC keyword.
- Static members are preloaded in the memory.
- A static variable is a variable that will be the same in all instances of a class.
- The initial value of a static variable is the default value of the variable’s type.
- A field declared with the static modifier is called a static variable. A static variable comes into existence before execution of the static constructor.
- Normally each class as its own copy of all variables. If you declare some as static, then they will have the same value in each instance of a class.
- Static methods show have static keyword as the method definition
- Static methods are accessed without creating an instance of the class object
- Static methods will not have “this” functionality to access the method
- Static methods cannot access non static members of the class.
- A nested class is one that is created inside another class.
- Nested classes have access to the private members of the outer class. So a scenario where this is the right way would be when creating a Comparer (ie. implementing the IComparer interface).
- Nested classes are very useful for implementing internal details that should not be exposed.
Disclaimer – F5debug Interview Questions & Answers Series:
You may recopy extracts from these pages (“the material”) to individual third party websites or to any intranet websites, but only if:
You acknowledge www.f5debug.net as the source of the material. Such acknowledgment should include reference to www.f5debug.net in the copy of the material and should also include “© Karthikeyan Anbarasan, www.f5debug.net “. You inform the third party that these conditions apply to him/her and that he/she must comply with them.