shadowing, overloading, and overriding

shadowing, overloading, and overriding

Shadowing, similar to Overloads, allows you to define a method that has the same name as another method in a base class, but without having to ensure a different signature.

You can also shadow a method that is defined in the same class using the Shadows keyword and a different signature, however this has the similar effect of overloading a method and can be used when your intent is to overload and protect your methods at the same time. And since the Shadows keyword is the default, declaring multiple methods with the same name and different signatures without using either keyword is enough to ensure they are both overloaded and shadowed (I never said this was simple!).
shadowing, overloading, and overriding

Shadowing, similar to Overloads, allows you to define a method that has the same name as another method in a base class, but without having to ensure a different signature.

You can also shadow a method that is defined in the same class using the Shadows keyword and a different signature, however this has the similar effect of overloading a method and can be used when your intent is to overload and protect your methods at the same time. And since the Shadows keyword is the default, declaring multiple methods with the same name and different signatures without using either keyword is enough to ensure they are both overloaded and shadowed (I never said this was simple!).

shadowing, overloading, and overriding

shadowing, overloading, and overriding

Shadowing, similar to Overloads, allows you to define a method that has the same name as another method in a base class, but without having to ensure a different signature.

You can also shadow a method that is defined in the same class using the Shadows keyword and a different signature, however this has the similar effect of overloading a method and can be used when your intent is to overload and protect your methods at the same time. And since the Shadows keyword is the default, declaring multiple methods with the same name and different signatures without using either keyword is enough to ensure they are both overloaded and shadowed (I never said this was simple!).
shadowing, overloading, and overriding

Shadowing, similar to Overloads, allows you to define a method that has the same name as another method in a base class, but without having to ensure a different signature.

You can also shadow a method that is defined in the same class using the Shadows keyword and a different signature, however this has the similar effect of overloading a method and can be used when your intent is to overload and protect your methods at the same time. And since the Shadows keyword is the default, declaring multiple methods with the same name and different signatures without using either keyword is enough to ensure they are both overloaded and shadowed (I never said this was simple!).

Primary Key Vs Unique Key


Primary Key :
1) Clustered index
2) It doesn't allow duplicates & NULL values.

Unique Key:
1) Non-clustered Index
2) It doesn't allow duplicates but it allows only one NULL value.


Clustered Index :
1) It store the directly value in a B-Tree Format.
2) A table contain only one Clusted Index

Non-Clustered Index:
1) It store the Address of the value in a B-Tree Format.
2) A table contain more than one Non-clustered Index

Primary Key :
1) Clustered index
2) It doesn't allow duplicates & NULL values.

Unique Key:
1) Non-clustered Index
2) It doesn't allow duplicates but it allows only one NULL value.


Clustered Index :
1) It store the directly value in a B-Tree Format.
2) A table contain only one Clusted Index

Non-Clustered Index:
1) It store the Address of the value in a B-Tree Format.
2) A table contain more than one Non-clustered Index

Primary Key Vs Unique Key


Primary Key :
1) Clustered index
2) It doesn't allow duplicates & NULL values.

Unique Key:
1) Non-clustered Index
2) It doesn't allow duplicates but it allows only one NULL value.


Clustered Index :
1) It store the directly value in a B-Tree Format.
2) A table contain only one Clusted Index

Non-Clustered Index:
1) It store the Address of the value in a B-Tree Format.
2) A table contain more than one Non-clustered Index

Primary Key :
1) Clustered index
2) It doesn't allow duplicates & NULL values.

Unique Key:
1) Non-clustered Index
2) It doesn't allow duplicates but it allows only one NULL value.


Clustered Index :
1) It store the directly value in a B-Tree Format.
2) A table contain only one Clusted Index

Non-Clustered Index:
1) It store the Address of the value in a B-Tree Format.
2) A table contain more than one Non-clustered Index

OOPS Concepts

Operator overloading :

C# operator definitions are class members that define or redefine the behavior of basic C# operators (called implicitly or explicitly) on instances of the class:



public class Complex

{

private double re, im;



public double Real

{

get { return re; }

set { re = value; }

}



public double Imaginary

{

get { return im; }

set { im = value; }

}



// binary operator overloading

public static Complex operator +(Complex c1, Complex c2)

{

return new Complex() { Real = c1.Real + c2.Real, Imaginary = c1.Imaginary + c2.Imaginary };

}



// unary operator overloading

public static Complex operator -(Complex c)

{

return new Complex() { Real = -c.Real, Imaginary = -c.Imaginary };

}



// cast operator overloading (both implicit and explicit)

public static implicit operator double(Complex c)

{

// return the modulus - sqrt(x^2 + y^2)

return Math.Sqrt(Math.Pow(c.Real, 2) + Math.Pow(c.Imaginary, 2));

}



public static explicit operator string(Complex c)

{

// we should be overloading the ToString() method, but this is just a demonstration

return c.Real.ToString() + " + " + c.Imaginary.ToString() + "i";

}

}



public class StaticDemo

{

public static void Main()

{

Complex number1 = new Complex() { Real = 1, Imaginary = 2 };

Complex number2 = new Complex() { Real = 4, Imaginary = 10 };

Complex number3 = number1 + number2; // number3 now has Real = 5, Imaginary = 12



number3 = -number3; // number3 now has Real = -5, Imaginary = -12

double testNumber = number3; // testNumber will be set to the absolute value of number3

Console.WriteLine((string)number3); // This will print "-5 + -12i".

// The cast to string was needed because that was an explicit cast operator.

}

}

Operator overloading :

C# operator definitions are class members that define or redefine the behavior of basic C# operators (called implicitly or explicitly) on instances of the class:



public class Complex

{

private double re, im;



public double Real

{

get { return re; }

set { re = value; }

}



public double Imaginary

{

get { return im; }

set { im = value; }

}



// binary operator overloading

public static Complex operator +(Complex c1, Complex c2)

{

return new Complex() { Real = c1.Real + c2.Real, Imaginary = c1.Imaginary + c2.Imaginary };

}



// unary operator overloading

public static Complex operator -(Complex c)

{

return new Complex() { Real = -c.Real, Imaginary = -c.Imaginary };

}



// cast operator overloading (both implicit and explicit)

public static implicit operator double(Complex c)

{

// return the modulus - sqrt(x^2 + y^2)

return Math.Sqrt(Math.Pow(c.Real, 2) + Math.Pow(c.Imaginary, 2));

}



public static explicit operator string(Complex c)

{

// we should be overloading the ToString() method, but this is just a demonstration

return c.Real.ToString() + " + " + c.Imaginary.ToString() + "i";

}

}



public class StaticDemo

{

public static void Main()

{

Complex number1 = new Complex() { Real = 1, Imaginary = 2 };

Complex number2 = new Complex() { Real = 4, Imaginary = 10 };

Complex number3 = number1 + number2; // number3 now has Real = 5, Imaginary = 12



number3 = -number3; // number3 now has Real = -5, Imaginary = -12

double testNumber = number3; // testNumber will be set to the absolute value of number3

Console.WriteLine((string)number3); // This will print "-5 + -12i".

// The cast to string was needed because that was an explicit cast operator.

}

}

OOPS Concepts

Operator overloading :

C# operator definitions are class members that define or redefine the behavior of basic C# operators (called implicitly or explicitly) on instances of the class:



public class Complex

{

private double re, im;



public double Real

{

get { return re; }

set { re = value; }

}



public double Imaginary

{

get { return im; }

set { im = value; }

}



// binary operator overloading

public static Complex operator +(Complex c1, Complex c2)

{

return new Complex() { Real = c1.Real + c2.Real, Imaginary = c1.Imaginary + c2.Imaginary };

}



// unary operator overloading

public static Complex operator -(Complex c)

{

return new Complex() { Real = -c.Real, Imaginary = -c.Imaginary };

}



// cast operator overloading (both implicit and explicit)

public static implicit operator double(Complex c)

{

// return the modulus - sqrt(x^2 + y^2)

return Math.Sqrt(Math.Pow(c.Real, 2) + Math.Pow(c.Imaginary, 2));

}



public static explicit operator string(Complex c)

{

// we should be overloading the ToString() method, but this is just a demonstration

return c.Real.ToString() + " + " + c.Imaginary.ToString() + "i";

}

}



public class StaticDemo

{

public static void Main()

{

Complex number1 = new Complex() { Real = 1, Imaginary = 2 };

Complex number2 = new Complex() { Real = 4, Imaginary = 10 };

Complex number3 = number1 + number2; // number3 now has Real = 5, Imaginary = 12



number3 = -number3; // number3 now has Real = -5, Imaginary = -12

double testNumber = number3; // testNumber will be set to the absolute value of number3

Console.WriteLine((string)number3); // This will print "-5 + -12i".

// The cast to string was needed because that was an explicit cast operator.

}

}

Operator overloading :

C# operator definitions are class members that define or redefine the behavior of basic C# operators (called implicitly or explicitly) on instances of the class:



public class Complex

{

private double re, im;



public double Real

{

get { return re; }

set { re = value; }

}



public double Imaginary

{

get { return im; }

set { im = value; }

}



// binary operator overloading

public static Complex operator +(Complex c1, Complex c2)

{

return new Complex() { Real = c1.Real + c2.Real, Imaginary = c1.Imaginary + c2.Imaginary };

}



// unary operator overloading

public static Complex operator -(Complex c)

{

return new Complex() { Real = -c.Real, Imaginary = -c.Imaginary };

}



// cast operator overloading (both implicit and explicit)

public static implicit operator double(Complex c)

{

// return the modulus - sqrt(x^2 + y^2)

return Math.Sqrt(Math.Pow(c.Real, 2) + Math.Pow(c.Imaginary, 2));

}



public static explicit operator string(Complex c)

{

// we should be overloading the ToString() method, but this is just a demonstration

return c.Real.ToString() + " + " + c.Imaginary.ToString() + "i";

}

}



public class StaticDemo

{

public static void Main()

{

Complex number1 = new Complex() { Real = 1, Imaginary = 2 };

Complex number2 = new Complex() { Real = 4, Imaginary = 10 };

Complex number3 = number1 + number2; // number3 now has Real = 5, Imaginary = 12



number3 = -number3; // number3 now has Real = -5, Imaginary = -12

double testNumber = number3; // testNumber will be set to the absolute value of number3

Console.WriteLine((string)number3); // This will print "-5 + -12i".

// The cast to string was needed because that was an explicit cast operator.

}

}

Interview Question part 3

Q 1)Can I deploy the application without deploying the source code on the server?


Ans)yes, After Project Completion we will Publish the Code after published we will give the code deploy the application on the server.
*************************************************************************
Q 2)Describe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe in the page loading process.



Ans) inetinfo.exe is theMicrosoft IIS server running, handling ASP.NET requests among other things.When an ASP.NET request is received (usually a file with .aspx extension),the ISAPI filter aspnet_isapi.dll takes care of it by passing the request tothe actual worker process aspnet_wp.exe.

*************************************************************************

Q 3) Can we declare event and delegates in an interface?



Ans)No,we cannot declare delegates in interface however we can declare events in interface.

So interface can only contains the signature of the following members

Methods

Properties

Indexers

Events
Q 1)Can I deploy the application without deploying the source code on the server?


Ans)yes, After Project Completion we will Publish the Code after published we will give the code deploy the application on the server.
*************************************************************************
Q 2)Describe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe in the page loading process.



Ans) inetinfo.exe is theMicrosoft IIS server running, handling ASP.NET requests among other things.When an ASP.NET request is received (usually a file with .aspx extension),the ISAPI filter aspnet_isapi.dll takes care of it by passing the request tothe actual worker process aspnet_wp.exe.

*************************************************************************

Q 3) Can we declare event and delegates in an interface?



Ans)No,we cannot declare delegates in interface however we can declare events in interface.

So interface can only contains the signature of the following members

Methods

Properties

Indexers

Events