
LINQ & Delegates
LINQ query syntax, method syntax, delegates, events, lambda expressions, func/action
1What is a delegate in C#?
What is a delegate in C#?
Câu trả lời
A delegate is a type that represents references to methods with a particular signature. It allows passing methods as parameters, storing them in variables, and invoking them dynamically. Delegates are the foundation of events and callbacks in C#, providing essential flexibility for event-driven programming and design patterns like Strategy or Observer.
2What is the correct syntax for declaring a simple lambda expression?
What is the correct syntax for declaring a simple lambda expression?
Câu trả lời
The syntax (x) => x * 2 is the correct form for a lambda expression. The => symbol (called the "lambda operator") separates parameters from the expression or method body. This concise syntax allows creating inline anonymous functions, very useful with LINQ or for passing behaviors as parameters. Parentheses around the parameter can be omitted if there is only one.
3Which generic delegate should be used for a method that takes an int and returns a string?
Which generic delegate should be used for a method that takes an int and returns a string?
Câu trả lời
Func<int, string> is the appropriate generic delegate because Func is used for methods that return a value. The convention is that the last type parameter represents the return type, and the preceding ones represent input parameters. Func can accept up to 16 input parameters. For methods with no return value, Action should be used instead of Func.
What is the main difference between Func and Action?
What does LINQ stand for?
+17 câu hỏi phỏng vấn
Các chủ đề phỏng vấn .NET khác
C# Basics
C# Language Essentials
ASP.NET Core Fundamentals
ASP.NET Core Request Lifecycle
Configuration & Settings
Application Lifecycle
Dependency Injection
Entity Framework Core
Minimal APIs
Web API Development
Async in ASP.NET Core
Authentication & Authorization
HttpClient & Networking
JSON Serialization
Entity Framework Core Advanced
C# Advanced Features
Clean Architecture
Logging, Monitoring & Observability
Unit Testing & xUnit
Integration Testing
Docker & Containerization
NuGet Package Management
Memory Management & GC
Reactive Programming
Async/await & Patterns
.NET Design Patterns
Performance Optimization
Security & Best Practices
SignalR & Real-time
Microservices Architecture
Nắm vững .NET cho lần phỏng vấn tiếp theo
Truy cập tất cả câu hỏi, flashcards, bài kiểm tra kỹ thuật, bài tập code review và mô phỏng phỏng vấn.
Bắt đầu miễn phí