Câu hỏi phỏng vấn C#
Câu hỏi

What is an anonymous function in C#?

Câu trả lời

An anonymous function in C# is a function that has no name and is defined without a formal method declaration. It is typically used when you need a simple function for a short period of time, such as when passing a function as an argument to another method or when using LINQ (Language Integrated Query) to query and manipulate data.

There are two main types of anonymous functions in C#:

Lambda Expressions

Lambda expressions are the most common form of anonymous functions in C#. They use the lambda operator (=>) to separate the function parameters from the function body. The syntax for a lambda expression is:

csharp Copy
(parameters) => expression

or

csharp Copy
(parameters) => { statements; }

Here's an example of a lambda exp...

middle

middle

Gợi ý câu hỏi phỏng vấn

expert

What's the difference between the System.Array.CopyTo() and System.Array.Clone() ?

senior

When to use ArrayList over array[] in C#?

expert

in C#, when should we use abstract classes instead of interfaces with extension methods?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào