Inversion of Control, Dependency Injection and Service Locator in C#

Posted 4 CommentsPosted in .net,

In this article, we will learn:   What is Dependency Inversion Principle (DIP) What is Inversion of Control (IOC) What is  Service Locator? What is Dependency Injection? Difference between DIP and IOC (DIP vs IoC) Difference between Dependency Injection and Service Locator (DI vs SL)   Many developers get confused with the term Dependency Injection. mainly […]

Design Patterns overview in C# (Part – 1)

Posted 1 CommentPosted in .net, .net Framework,,

In this article, we will discuss the overview of Design patterns in C#. Let’s understand what is Pattern? “Pattern is a recurring solution to a problem in a context“. “Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in […]

var vs Dynamic in C#

Posted Posted in .net,

var dynamic Introduced in C# 3.0 Introduced in C# 4.0 Statically typed – This means the type of variable declared is decided by the compiler at compile time. Dynamically typed – This means the type of variable declared is decided by the compiler at run time. var type of variables are required to be initialized […]

String vs StringBuilder in C#

Posted Posted in .net,

String StringBuilder A string (namespace: System.String ) is a sequential collection of Unicode characters that represents text A StringBuilder (System.Text.StringBuilder) represents a mutable string of characters. This class cannot be inherited. String is immutable, Immutable means if you create string object then you cannot modify it and It always create new object of string type […]

Virtual,Override and New Keyword in C#

Posted Posted in .net,

Generally virtual and override keywords will occur in overriding method of polymorphism concept and new keyword will be used to hide the method. Here we will discuss these keywords with example. Virtual Keyword: Virtual keyword is used for generating a virtual path for its derived classes on implementing method overriding. Virtual keyword is used within a set with override keyword. […]

Delegates vs Interfaces in C#

Posted Posted in .net,

Delegates: Delegates are reference-types, so they allocate an entire object only to reference a method. Delegates are the fastest to call when you know all parameter types at compile-time. Delegates allow the use of anonymous delegates which really simplify creating single-line or very small delegates. Delegates can reference a private method without the requirement to […]

Difference between == and .Equals method in csharp

Posted Posted in .net,

For Value Type: == and .Equals() method usually compare two objects by value. For Example: int x = 20; int y = 20; Console.WriteLine( x == y); Console.WriteLine(x.Equals(y)); Output: True True For Reference Type: == performs an identity comparison, i.e. it will only return true if both references point to the same object. While Equals() […]