What is Recursion | Recursive Function
Recursive function is a function that calls itself. Let’s look at the following example, using System; namespace ConsoleApp12 { class Program { static void Main(string[] args) { var factorialOf = factorial(5); Console.WriteLine(factorialOf); Console.ReadKey(); } public static int factorial(int input) { if (input == 1 || input == 0) return 1; else return input […]
Read MoreInsertion Sort
using System; namespace ZeroToCSharp { class Program { static void Main(string[] args) { int[] array = new int[6] { 24, 6, 26, 11, 15, 3 }; int key, comparer; for (int i = 1; i < array.Length; i++) { key = array[i]; comparer = i – 1; while(comparer >= 0 && array[comparer] > […]
Read MoreBubble Sort
using System; namespace ZeroToCSharp { class Program { static void Main(string[] args) { int[] array = new int[6] { 24, 6, 26, 11, 15, 3 }; int temp; bool isSwapped; for (int i = 0; i < array.Length – 1; i++) { isSwapped = false; for (int j = 0; j < array.Length […]
Read MoreSelection Sort
using System; namespace ZeroToCSharp { class Program { static void Main(string[] args) { int[] array = new int[6] { 24, 6, 26, 11, 15, 3 }; int min, temp; for (int i = 0; i < array.Length – 1; i++) { min = i; for (int j = i + 1; j […]
Read MoreWhat is Garbage Collector?
In C#, every created object allocates memory. And we can need some memory space for any other objects. So these memory addresses need to be deallocate. This could be possible by managing memory manually(mostly in old languages). But C# has an automatic memory manager and it is called Garbage Collector (GC). Garbage Collector releases […]
Read MorePointer
Pointer keeps the memory address of arrays and value types. Garbage Collector does not track pointer types. (You can see more detail here about Garbage Collector). Unsafe context is used to run code outside the control of Garbage Collector.
Read MoreString
String is a data type that can hold texts. String is reference type variable. But when you pass a string to a variable or a method, it does not reference variable. Because string is immutable reference type. That means you cannot change string after it is created. Every change to a string will create a […]
Read MoreObject
Object is a data type that can hold properties without explicitly defining a type like class. Object is reference type variable. So when you pass an object to a variable or a method, it references variable. This means when you change copied variable, it will change the main variable too. Or changing main variable will […]
Read MoreInterface
Interface is a data type that can hold properties and functionalities. Interface is reference type variable. So when you pass an interface to a variable or a method, it references variable. This means when you change copied variable, it will change the main variable too. Or changing main variable will change the copied variable. […]
Read More