🔷
Backend Platform · Arena

.NET / ASP.NET Core

165 challenges · 0 mastered

0%
Arena cleared
0/165 mastered Let's go 🚀
Answer

C# is an object oriented programming language developed by Microsoft mainly used for building web applications, APIs, desktop applications, and backend services.

Code Example
string name = "Manav";
💡 Simple Analogy

C# is the main language we use to write .NET applications.

Answer

CLR stands for Common Language Runtime. It executes .NET code and handles memory management, exception handling, and garbage collection.

Code Example
// CLR executes compiled IL code
💡 Simple Analogy

CLR is like the engine that runs .NET code.

Answer

Value types store actual data directly while reference types store memory address pointing to actual object.

Code Example
int a = 5; string name = "test";
💡 Simple Analogy

int stores value directly, object stores reference.

Answer

var type is decided at compile time while dynamic type is decided at runtime.

Code Example
var x = 10; dynamic y = 10;
💡 Simple Analogy

var is fixed after compile, dynamic can change while running.

Answer

Boxing converts value type to object type and unboxing converts object back to value type.

Code Example
int a = 10; object obj = a; int b = (int)obj;
💡 Simple Analogy

Wrapping int inside object is boxing.

Answer

Method overloading means creating multiple methods with same name but different parameters.

Code Example
Add(int a,int b)
Add(int a,int b,int c)
💡 Simple Analogy

Same method name but different input.

Answer

Method overriding means changing parent class method behavior in child class using virtual and override keywords.

Code Example
public override void Show(){}
💡 Simple Analogy

Child class changes parent method behavior.

Answer

Encapsulation means hiding internal data and exposing only required functionality using properties and methods.

Code Example
private int age; public int Age { get; set; }
💡 Simple Analogy

Hide data and allow controlled access.

Answer

Inheritance allows child class to reuse properties and methods from parent class.

Code Example
class Admin : User {}
💡 Simple Analogy

Child class gets parent functionality.

Answer

Polymorphism allows same method to behave differently depending on object or parameters.

Code Example
method overloading and method overriding
💡 Simple Analogy

Same method, different behavior.

Answer

Abstraction means hiding implementation details and showing only important functionality.

Code Example
abstract class Payment {}
💡 Simple Analogy

User sees what action does, not internal logic.

Answer

Abstract class can have implementation and constructor while interface only defines contract.

Code Example
interface IUserService {}
💡 Simple Analogy

Interface defines what to do, abstract can partially implement.

Answer

Yes a class can implement multiple interfaces in C#.

Code Example
class User : ILogin, IRegister {}
💡 Simple Analogy

One class can follow multiple contracts.

Answer

Array has fixed size while List is dynamic and can grow or shrink.

Code Example
int[] arr = new int[5]; List<int> list = new();
💡 Simple Analogy

Array fixed, List flexible.

Answer

Dictionary stores data as key value pairs and allows fast lookup using key.

Code Example
Dictionary<int,string> users = new();
💡 Simple Analogy

Store like ID and Name together.

Answer

IEnumerable works in memory while IQueryable executes query on database side.

Code Example
db.Users.Where(x => x.Id > 1)
💡 Simple Analogy

IQueryable filters in DB, IEnumerable filters after data comes.

Answer

Queue follows FIFO structure meaning first in first out.

Code Example
Queue<int> q = new();
💡 Simple Analogy

First inserted item comes out first.

Answer

Stack follows LIFO structure meaning last in first out.

Code Example
Stack<int> stack = new();
💡 Simple Analogy

Last inserted item comes out first.

Answer

Exception handling allows application to handle runtime errors without crashing.

Code Example
try { } catch(Exception ex) { }
💡 Simple Analogy

Handle errors safely.

Answer

Try contains risky code, catch handles error, finally always executes.

Code Example
try{} catch{} finally{}
💡 Simple Analogy

Finally runs whether error happens or not.

Answer

throw keeps original stack trace while throw ex resets stack trace.

Code Example
throw; vs throw ex;
💡 Simple Analogy

Use throw to preserve original error details.

Answer

Finally is used for cleanup like closing DB connection or releasing resources.

Code Example
finally { connection.Close(); }
💡 Simple Analogy

Always runs at end.

Answer

Create class inheriting Exception class.

Code Example
class MyException : Exception {}
💡 Simple Analogy

Create your own custom error.

Answer

Delegate is a type safe function pointer that holds reference to methods.

Code Example
delegate void Print();
💡 Simple Analogy

Delegate points to a method.

Answer

Event allows one class to notify other classes when something happens.

Code Example
public event EventHandler OnSave;
💡 Simple Analogy

Button click triggers event.

Answer

Delegate can directly call methods while event is used for notifications and restricts direct invocation outside class.

Code Example
event EventHandler Submit;
💡 Simple Analogy

Event is safer wrapper around delegate.

Answer

Action is built in delegate that returns no value.

Code Example
Action<string> print;
💡 Simple Analogy

Method runs but returns nothing.

Answer

Func is built in delegate that returns a value.

Code Example
Func<int,int,int> add;
💡 Simple Analogy

Method takes input and returns result.