0% found this document useful (0 votes)
5 views3 pages

C#-Test 2

The document explains several C# programming concepts including anonymous functions, lambda functions, and dependency injection, highlighting their definitions and differences. It also covers concrete classes, the difference between 'is' and 'as' operators, the null coalescing operator, and partial classes. Each concept is succinctly described to provide a foundational understanding of their roles in C# programming.

Uploaded by

ritup4040
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

C#-Test 2

The document explains several C# programming concepts including anonymous functions, lambda functions, and dependency injection, highlighting their definitions and differences. It also covers concrete classes, the difference between 'is' and 'as' operators, the null coalescing operator, and partial classes. Each concept is succinctly described to provide a foundational understanding of their roles in C# programming.

Uploaded by

ritup4040
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

1.

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.

6. What is Null Coalesce operator?


The null-coalescing operator ?? returns the value of its left-hand operand if it isn't null; otherwise, it
evaluates the right-hand operand and returns its result. The ?? operator doesn't evaluate its right-hand
operand if the left-hand operand evaluates to non-null.

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.

You might also like