Exception Handling in C#
Context / Idea: Exception handling is used to handle runtime errors using try, catch and finally
blocks.
Code:
try
{
int a = 10;
int b = 0;
[Link](a / b);
}
catch (Exception e)
{
[Link]("Error occurred");
}
finally
{
[Link]("Program ended");
}
For Loop in C#
Context / Idea: A for loop is used when the number of iterations is known beforehand.
Code:
for (int i = 1; i <= 5; i++)
{
[Link](i);
}
Default and Copy Constructor
Context / Idea: Default constructor initializes objects. Copy constructor copies one object into
another.
Code:
class Student
{
public int age;
public Student()
{
age = 18;
}
public Student(Student s)
{
age = [Link];
}
}
File Operations in C#
Context / Idea: File handling allows permanent data storage using [Link].
Code:
[Link]("[Link]", "Hello File");
string data = [Link]("[Link]");
[Link](data);
CRUD Application (Console)
Context / Idea: CRUD stands for Create, Read, Update and Delete operations.
Code:
List<string> users = new List<string>();
[Link]("Ali");
[Link]("Sara");
users[0] = "Ahmed";
[Link]("Sara");
EF Core Data Model
Context / Idea: EF Core maps C# classes to database tables.
Code:
public class Student
{
public int Id { get; set; }
public string Name { get; set; }
}
JavaScript DOM Manipulation
Context / Idea: DOM manipulation allows dynamic changes to HTML using JavaScript.
Code:
[Link]("msg").innerHTML = "Changed!";
JavaScript Closure
Context / Idea: A closure allows a function to remember variables from its outer scope.
Code:
function counter() {
let count = 0;
return function () {
count++;
[Link](count);
}
}