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

What is the difference bet...

Câu trả lời

Here is the difference between Lambdas and Delegates in C#:

Lambdas

  • Lambdas are anonymous functions that can be passed as arguments to methods or assigned to variables.
  • They are defined using the => operator, which separates the lambda's parameters from its body.
  • Lambdas can capture variables from their enclosing scope, allowing them to access and modify variables outside of their own body.
  • Lambdas are often used with LINQ queries and methods like Where, Select, OrderBy, etc.
  • Example:
    csharp Copy
    Func<int, int> square = x => x * x;
    int result = square(5); // result = 25

Delegates

  • Delegates are types that represent methods with a particular signature (return type and parameter types).
  • They are declared with a method signature and can be assigned to variables or p...
expert

expert

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

expert

You have defined a destructor in a class that you have developed by using the C#, but the destructor
never executed. Why?

middle

What is the difference between overloading and overriding?

junior

What is Managed or Unmanaged Code?

Bình luận

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

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