Factorial in C Sharp

Factorial For a number n, the product of all its positive descending integers is called it’s factorial which is denoted by n! and is pronounced as “n factorial”, it is also called “n bang” or “n shriek”. In Combinations and Permutations in mathematics, the factorial of a number is used. For example: 5! = 5*4*3*2*1 … Read more

Categories C#

Palindrome Number in C Sharp

Palindrome Number A palindrome number is a number which is the same as its reverse number. For example, 111, 56765, 42424, 234565432, etc. Algorithm: Take the input from the user. Store the number in a temporary variable. Create the reverse of the number. Compare both the numbers. Print the number as a palindrome number, if … Read more

Categories C#

Prime Number in C Sharp

Prime Number A Prime number is a number that can be divided either by itself or 1. For example, 2, 3, 5, 7, 11, 13, 17, 19, 23, etc. Example: using System; public class Example { public static void Main(string[] args) { int num, i, x=0, f=0; Console.Write("Enter a Number: "); num = int.Parse(Console.ReadLine()); x … Read more

Categories C#

Fibonacci Series in C Sharp

Fibonacci Series A Fibonacci series is a series of numbers where the next number is a sum of the previous two numbers. For example, a Fibonacci series with the first two numbers of 1 and 2 is: 1, 2, 3, 5, 8, 13, 21, 34 etc. Example: using System; public class Example { public static … Read more

Categories C#

C Sharp Thread Synchronization

C# Thread Synchronization To allow only one thread to access the resource for a specified time, the technique of synchronization is used in C#. Until the specified task is completed by the assigned thread, no other thread can interrupt. Threads in a multithreading program can access any resource for the desired execution time, thus sharing … Read more

Categories C#

C Sharp ThreadPriority

C# ThreadPriority In C# we can change the priority of the thread. The thread with the highest priority is thus executed first. The thread is however highly system dependent, thus it is not guaranteed but the chance of the execution of the high priority thread before low priority thread is increased. Example: using System; using … Read more

Categories C#

C Sharp Thread Name

C# Thread Name The Name property of the Thread class can be used to change or get the name of the thread. Example: using System; using System.Threading;   public class Example { public void thrd1() { Thread x = Thread.CurrentThread; Console.WriteLine("The running thread is: " + x.Name); } } public class thrd2 { public static … Read more

Categories C#

C Sharp Thread Join

C# Thread Join To instruct the calling threads to wait until the current thread or the joined thread is terminated or completes the specified task, the join() method is used in C#. Example: using System; using System.Threading; public class Example { public void thrd1() { for (char i = ‘a’; i < ‘g’; i++) { … Read more

Categories C#

C Sharp Thread Abort

C# Thread Abort To terminate the thread, the Abort() method is used in C#. In case the Abort operation is not done, the ThreadAbortException exception is raised. Example: using System; using System.Threading; public class Example { public void thrd1() { for (char i = ‘a’; i < ‘g’; i++) { Console.WriteLine(i); Thread.Sleep(100); } } } … Read more

Categories C#

C Sharp Thread Sleep

C# Thread Sleep To suspend the current thread for a specified time in milliseconds to give the chance to the other threads to start execution, the Sleep() method is used in C#. Example: using System; using System.Threading; public class Example { public void thrd1() { for (char i = ‘a’; i < ‘g’; i++) { … Read more

Categories C#