Saturday, 19 December 2020

TFS Vs GIT

 GIT TFS

Push Check-in

Pull         Get latest

Stash Shelve Set

Saturday, 25 April 2020

Difference between peek and keep in Tempdata from MVC

Peek : Retain the value from another request
Keep: Retaining the value depends on additional logic

Saturday, 14 March 2020

Sealed Class Usage with Examples

Sealed will prevent the class from inheriting to other class.
Sealed class can contain both the static method and non static method.
Static method should be called without object creation.
Non static method should be called by creating the static method.

Example:

sealed class AA
    {
        public static string SealedwithStaticMethod()
        {
            return "SealedwithStaticMethod";
        }
        public  string SealedwithOUTStaticMethod()
        {
            return "SealedwithOUTStaticMethod";
        }
    }

Program.cs

Console.WriteLine(AA.SealedwithStaticMethod());
 AA dc = new AA();
Console.WriteLine(dc.SealedwithOUTStaticMethod());

OUTPUT:

Sunday, 23 February 2020

Inheritance

Normal Inheritance

class A
    {
        public virtual string PrintVirtual()
        {
            return "A virtual Class";
        }
    }

    class B:A
    {
        public virtual string PrintVirtual()
        {
            return "B virtual Class";
        }
    }
    class C:B
    {
        public virtual string PrintVirtual()
        {
            return "C virtual Class";
        }
    }

A dc = new B();
Console.WriteLine(dc.PrintVirtual());

Output:
A virtual Class

A dc = new C();
Console.WriteLine(dc.PrintVirtual());

Output:
A virtual Class

B dc = new C();
Console.WriteLine(dc.PrintVirtual());

Output:
B virtual Class

Abstract Inheritance

    abstract class A
    {
        public abstract string PrintVirtual();
    }

    class B:A
    {
        public override string PrintVirtual()
        {
            return "B abstract Class";
        }
    }
    class C:B
    {
        public override string PrintVirtual()
        {
            return "C abstract Class";
        }

    }

A dc = new B();
Console.WriteLine(dc.PrintVirtual());

Output
B abstract Class

A dc = new C();
Console.WriteLine(dc.PrintVirtual());

Output
C abstract Class

Error Handling in MVC

1.Handle Error Attribute
2.It will be Registered in filter config
3.In web.config on custom error
4.Error Page in shared folder will be triggered when error occurred.
5.404 status code should be configured in web.config