Friday, 5 February 2021

Difference Between Dictionary And Hashtable In C#

 


Dictionary 
1.Dictionary is generic type Dictionary<TKey,TValue>
2.Dictionary class is a strong type < TKey,TValue > Hence, you must specify the data types for key and value.
3.There is no need of boxing/unboxing.
4.When you try to access non existing key dictionary, it gives runtime error.
5.Dictionary maintains an order of the stored values.
6.There is no need of boxing/unboxing, so it is faster than Hashtable.

"e.g Dictionary<string, string> EmployeeList = new Dictionary<string, string>();  
EmployeeList.Add(""Mahesh Chand"", ""Programmer"");  
EmployeeList.Add(""Praveen Kumar"", ""Project Manager"");  
EmployeeList.Add(""Raj Kumar"", ""Architect"");  
EmployeeList.Add(""Nipun Tomar"", ""Asst. Project Manager"");  
EmployeeList.Add(""Dinesh Beniwal"", ""Manager"");  "

Hashtable 
1.Hashtable is non-generic type.
2.Hashtable is a weakly typed data structure, so you can add keys and values of any object type.
3.Values need to have boxing/unboxing.
4.When you try to access non existing key Hashtable, it gives null values.
5.Hashtable never maintains an order of the stored values.
6.Hashtable needs boxing/unboxing, so it is slower than Dictionary.

"e.g Hashtable HT = new Hashtable();    
HT.Add(1,""s"");    
HT.Add(3, ""n"");    
HT.Add(4, ""j"");    
HT.Add(2, ""a"");    
HT.Add(5, ""u"");  "







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

Saturday, 7 December 2019

Cache Issue On Client Side

Following points have been used for cache issue during upgrade of the application on the Client side
1.Fiddler - Cache Clearing
2.Version Change in bundle
3.IIS Reset
4.IIS -> Output Caching
5."inetpub" temp files delete