{ "title": "C# Algorithm and Data Structure", "sections": [ { "title": "C# Algorithm Common Functions", "content": { "Mathematical Functions": { "Math.Abs(number)": "Returns the absolute value of a number.", "Math.Max(x, y)": "Returns the larger of two numbers.", "Math.Min(x, y)": "Returns the smaller of two numbers.", "Math.Round(value)": "Rounds a number to the nearest integer." }, "String Functions": { "string.Length": "Gets the length of a string.", "string.ToUpper()": "Converts all characters in a string to uppercase.", "string.ToLower()": "Converts all characters in a string to lowercase.", "string.Substring(startIndex, length)": "Extracts a substring from a string." } } }, { "title": "C# Data Structure", "content": { "Array": { "Definition": "An array is a collection of elements of the same type stored at contiguous memory locations.", "Example": [ "int[] numbers = new int[5];", "int[] numbers = {1, 2, 3, 4, 5};" ] }, "Multi-dimensional Array": { "Definition": "An array with more than one dimension is called a multi-dimensional array.", "Example": [ "int[,] matrix = new int[3, 3];", "int[,] matrix = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} }" ] }, "Collection Framework": { "List<T>": "A dynamic array that can grow or shrink as needed.", "Dictionary<TKey, TValue>": "A collection of keys and values that allows for efficient retrieval.", "Stack<T>": "A Last-In-First-Out (LIFO) collection.", "Queue<T>": "A First-In-First-Out (FIFO) collection." } } }, { "title": "C# Object-Oriented Programming", "content": { "Class and Objects": { "Definition": "A class is a blueprint for creating objects.", "Example": [ "public class Car {", " public string Model;", " public int Year;", " public void Start() { Console.WriteLine(\"Car started\"); }", "}", "Car myCar = new Car();", "myCar.Model = \"Toyota\";", "myCar.Year = 2020;", "myCar.Start();" ] }, "Inheritance": { "Definition": "A class can inherit properties and methods from another class.", "Example": [ "public class Animal {", " public void Speak() { Console.WriteLine(\"Animal speaks\"); }", "}", "public class Dog : Animal {", " public void Bark() { Console.WriteLine(\"Dog barks\"); }", "}" ] }, "Polymorphism": { "Definition": "A method can have the same name but different implementations in derived classes.", "Example": [ "public class Bird : Animal {", " public override void Speak() { Console.WriteLine(\"Bird tweets\"); }", "}" ] } } }, { "title": "C# Exception Handling", "content": { "Try-Catch-Finally": { "Definition": "A block of code that is used to catch and handle exceptions.", "Example": [ "try {", " int result = 10 / 0;", "} catch (DivideByZeroException e) {", " Console.WriteLine(e.Message);", "} finally {", " Console.WriteLine(\"Finally block executed\");", "}" ] }, "Custom Exceptions": { "Definition": "A user-defined exception class that can be used to handle specific error conditions.", "Example": [ "public class CustomException : Exception {", " public CustomException(string message) : base(message) { }", "}", "try {", " throw new CustomException(\"Custom error occurred\");", "} catch (CustomException e) {", " Console.WriteLine(e.Message);", "}" ] } } } ] }