Can we execute multiple catch blocks?
you can write multiple catch blocks for a try block, but only the exception block that closely matches the exception is executed.
you can write multiple catch blocks for a try block, but only the exception block that closely matches the exception is executed.
Arrays:
ArrayList:
An array of arrays is called a Jagged Array. Each individual array within the Jagged Array can be of variable length.
var jaggedArray = new int[10][];
jaggedArray[0] = new int[5];
jaggedArray[1] = new int[10];
jaggedArray[2] = new int[2];
The method of converting a value type into a reference type is called as BOXING
int a = 15;
string myString = a.ToString();
The conversion of a reference type into a value type is called as UNBOXING
string str = "15";
int val = int.parse(str);
virtual method:
abstract methods:
A sealed class is a type used to restrict users from extending the type. A type marked CANNOT be extended by inheritance, but can be referenced by an object.
public sealed MyClass {
// some code
}
// throws compilation error
public class SomeClass : MyClass {
}
These are the following access modifiers present in C#, which define how a component or a field can be accessed by the other components.
public - available for access by all other components inside or outside its class or assembly private - not available for access by any other component outside its class internal - available for access by other components only within its assembly protected - available for access by only its derived types protected internal - available for access by only its derived types or other components within its assembly
Managed Code refers to the components developed within the framework and which can be managed by the CLR for execution. These components can be managed by the framework itself and can be Garbage Collected.
Unmanaged Code refers to the components which are not developed within the framework and which need their own environment to be managed or executed. For example, C++ or assembly code which aren't managed or can't be garbage collected by the .NET framework directly.
These are called inside the Framework by means of wrappers.
For example if we have a Dictionary defined as:
class MyClass {
public MyClass(int id) {
this.Id = id
}
public int Id { get; set; }
}
Dictionary<MyClass, int> dict = new Dictionary<MyClass, int>();
dict.Add(new MyClass(1), 1);
dict.Add(new MyClass(2), 2);
dict.Add(new MyClass(3), 3);
To ensure that the Keys are always unique, we need to implement the GetHashCode() method for the MyClass which by default extends the System.Object class. This is the method that the Dictionary internally uses to compute HashKey for the Keys.