1/23
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What are the Loop types in C#?
While loop
Do While
For Loop
ForEach Loop
What is the difference between “continue” and “break” statement?
Continue statement end the loop iteration and transfer the control to the beginning of the loop.
Break statement end the loop iteration and exit the loop.
What are the alternative ways of writing if-else conditions?
Switch
Ternary
How to implement Exception Handling in C#?
Exception handling with Try, Catch, and Finally
Can we execute multiple Catch blocks?
NO
When to use Finally in real applications?
Finally block is mostly used to dispose the unwanted objects
Can we have only “Try” block without “Catch” block in real applications?
YES - but then we must have finally block with try block.
What is the difference between Finally and Finalize?
❖ Finally, is used in exception handling.
❖ Finalize is a method which is automatically called by the garbage collector to dispose the no longer needed objects
What is the difference between “throw ex” and “throw”?
Throw ex will change the stack trace, where as throw will preserve the whole stack trace.
Explain Generics in C#?
Make classes and methods - type independent or type safe.
EX: AreEqual<T>(T value1, T value2)
What are Collections in C# and what are their types?
Used to store, manage and manipulate data
EX: ArrayList, Dictionary, List, Hashtable
What is the difference between Array and ArrayList (atleast 2)?
Array is STRONGLY typed
Array elements are FIXED
ArrayList can Store any items\elements
ArrayList can store any amount of elements
What is the difference between Arraylist and Hashtable?
In Arraylist we can only add Items/ Values to the list.
Values
In Hashtable we can add Items/Values with the Keys.
Keys and Value
What is the difference between List and Dictionary Collections?
List is a collection of items.
It is the generic version of ArrayList
Dictionary is a collection of key value pair.
It is the generic version of Hashtable
What is IEnumerable in C#?
IEnumerable interface is used when we want to ITERATE among our collection classes using a FOREACH loop.
Interface that ITERATE collection in a FOREACH loop
What is the difference between IEnumerable and IEnumerator in C#?
IEnumerable internally uses IEnumerator only to iterate the collection via forach loop.
IEnumerable simplifies the use of IEnumerator.
What is the difference between IEnumerable and IQueryable in C#?
IQueryable inherited from IEnumerable interface only
Anything you can do with a IEnumerable, you can also do with an IQueryable also.
IEnumerable is used with in-memory collection.
IQueryable is better in getting result from database.
IQueryable is under SYSTEM.LINQ namespace. IEnuberable is under System.Collections namespace.
IQueryable filter the result at database only and then get only filtered result, therefore less network load and better performance.