| C# Question Answers-11 - 20 | C# Question Answers-31 - 40 | |
C# (C-Sharp) Question Answers - 21-30 |
Mixed Syntax: We can use a mixture of both syntax by enclosing a query expression inside parentheses and make a call to method.
// Data
List<int> numbers = new List<int>() { 11, 22, 33, 44, 55, 66, 77, 88, 99, 100 };
// Mixed syntax
int query = (from num in numbers where num > 55 && num < 100 select num).Count();
// result: 4
Query Syntax (Expression Query): It is like a SQL query syntax with just a few changes. The result of a query expression is a query object, which is usually a collection of type IEnumerable<T> or IQueryable<T>. This syntax is easy to read and write and at compile time, query expression is converted into Method Invocation.
// Data
List<int> numbers = new List<int>() { 11, 22, 33, 44, 55, 66, 77, 88, 99, 100 };
// Query based syntax
IEnumerable<int> query = from num in numbers where num > 55 && num < 100 select num;
// result: 66,77,88,99
private access modifier; prevents other classes from instantiating or deriving.Assembly qualified name contains Assembly Name, Version, Token key and Culture information. Stored as metadata and defines scope.
Generic Delegate was introduced in .NET 3.5 and doesn’t require defining delegate instances manually.
Both interfaces allow custom sorting:
Used to release unmanaged resources. Garbage collector releases managed memory automatically but cannot predict when. GC also doesn’t handle unmanaged resources like file handles or streams.
Dispose() performs tasks associated with freeing, releasing, or resetting unmanaged resources.
An interface is a contract defining behavior without implementation. A class that implements an interface must provide the methods and properties defined in the interface.
A multicast delegate can invoke multiple methods. Use + to add methods and - to remove methods. Methods execute in sequence.
| C# Question Answers-11 - 20 | C# Question Answers-31 - 40 | |