C#-Test 2
C#-Test 2
Anonymous Function:-
A anonymous method is a method which doesn’t contain any name. An Anonymous method is defined using
the delegate keyword and the user can assign this method to a variable of the delegate type.
2. Lambda Function:-
Lambda expressions in C# are used like anonymous function with the difference that in Lambda expressions
you don’t need to specify the type of the value that you input thus making it more flexible to use.
The ‘=>’ is the lambda operator which is used in all lambda expressions. The Lambda expression is divided
into two parts, the left side is the input and the right is the expression.
3. Dependency Injection:-
The Dependency Injection in C# is a process in which we can convert tight coupling into loose coupling. The
Dependency Injection Design Pattern is the most commonly used design pattern nowadays to remove the
dependencies between the objects.
Tight coupling:- This concept occurs when multiple classes are highly dependent on each other.
Loose coupling:- This concept occurs when classes are independent.
Problems in Tight coupling:-
When the classes are highly dependent on each other then if there is error or there are some
problem in one class then that will affect all the classes
Types of Dependency Injection:-
Constructor injection
Property injection
Method injection
4. Concrete Class:-
A concrete class is a class that is not abstract. It includes full implementations of all its members—methods,
properties, fields, etc. —and can be used to create objects.
5. Difference between is and as
The “is” operator checks if the type of an expression is same as given type.
The “as” operator explicitly converts the type of an expression to a given type.
7. Partial Class:- Partial class provides a special ability to implement the functionality of a single class into
multiple files and all these files are combined into a single class file when the application is compiled. A
partial class is created by using a partial keyword.