Home »
.Net »
C# Programs
C# Basic Programs
This section contains C# basic programs/examples with the output and explanation. These all implemented programs are written, compiled in the Visual studio. These programs are based on the simple printing messages, mathematical problems, date & time formats etc.
Here is the complete list of 500+ most popular C# basic programs along with explanations:
Basics C# Programs
- C# program to print messages/text (program to print Hello world)
- C# program to demonstrate example of Console.Write() and Console.WriteLine()
- C# program to print a new line
- C# program to print backslash (\)
- C# program to demonstrate the example of New keyword
- C# program to print size of various data types
- C# program for type conversion from double to int
- C# program to convert various data type to string using ToString() method
- C# program to define various types of constants
- C# program to declare different types of variables, assign the values and print
- C# program to input and print an integer number
- C# program to demonstrate example of arithmetic operators
- C# program to demonstrate example of assignment operators
- C# program to demonstrate example of sizeof() operator
- C# program to demonstrate example of equal to and not equal to operators
- C# program to demonstrate example of relational operators
- C# program to demonstrate example of bitwise operators
- C# program to find the addition of two integer numbers
- C# program to swap two numbers with and without using third variable
- C# | print type, max and min value of various data types
- C# program to swap numbers using XOR operator
- C# program to find the magnitude of an integer number
- C# program to demonstrate the example of the left-shift operator
- C# program to demonstrate the example of the right shift operator
- C# program to read the grade of students and print the appropriate description of grade
- C# program to calculate the size of the area in square-feet based on specified length and width
- C# program to find the division of exponents of the same base
- C# program to demonstrate the example goto statement
- C# program to print a message without using the WriteLine() method
- C# program to convert a binary number into a decimal number
- C# program to convert a decimal number into a binary number
- C# program to convert a decimal number into an octal number
- C# program to convert a hexadecimal number into a decimal number
- C# program to convert a decimal number into a hexadecimal number
- C# program to convert a meter into kilo-meter and vice versa
- C# program to convert a temperature from Celsius to Fahrenheit
- C# program to convert a temperature from Fahrenheit into Celsius
- C# program to create gray code
- C# program to change the case of entered character
- C# program to convert entered days into years, weeks, and days
- C# program to convert the US dollar into Indian rupees
- C# program to print digits of a number into words
- C# program to check the given number is a perfect number or not
- C# program to print the all factors of a given number
- C# program to find the HCF of two given numbers
- C# program to check given numbers are the pair of amicable numbers or not
- C# program to find the addition of two complex numbers
- C# program to find the greatest common divisor (GCD)
- C# program to find the value of sin(x)
- C# program to demonstrate the trigonometry angles in degrees using Math class
- C# program to demonstrate the trigonometry angles in radians using Math class
- C# program to calculate the MEAN of a set of given numbers
- C# program to calculate the VARIANCE of a set of given numbers
- C# program to calculate the Standard Deviation of a set of given numbers
- C# program to calculate the compound interest
- C# program to calculate the Cosine(X) using a predefined method
- C# program to calculate the Cosine(X) without using a predefined method
- C# program to calculate the traveled distance based on speed and time
- C# program to print the Pascal Triangle
- C# program to calculate the sum of two binary numbers
- C# program to calculate the multiplication of two exponents of the same base
- C# program to print Floyd's triangle
- C# program to calculate the multiplication of two numbers using the left shift operator
- C# program to print the edge values using Pow() method
- C# program to calculate the fractional power of numbers
- C# program to demonstrate the bitwise operations
- C# program to find the root of a quadratic equation
- C# program to print the absolute value of a number without using Math.Abs() method
- C# program to find the Least Common Multiple of two numbers
- C# program to find the cube root of a given number
- C# program to find the square root of a given number without using Math.Sqrt() method
- C# program to calculate the area of a Cone
- C# program to calculate the volume of a cone
- C# program to calculate the NPR
- C# program to calculate the area of Sphere
- C# program to calculate the volume of Sphere
- C# program to calculate the perimeter of Circle
- C# program to calculate the perimeter of Rectangle
- C# program to calculate the NCR
If Else (Conditional Statement) C# Programs
- C# program to demonstrate example of simple if else statement
- C# program to demonstrate example of multiple if else statement
- C# program to demonstrate example of nested if else statement
- C# program to demonstrate example of conditional operator
- C# program to demonstrate example of nested conditional operator
- C# program to demonstrate example of switch statement
- C# program to demonstrate example of nested switch statement
- C# program to read two numbers and find maximum, minimum number
- C# program to find largest of two numbers
- C# program to find largest of three numbers
- C# program for character comparison
- C# program to check given strings are equal or not using equal to (==) operator
- C# program to input weekday number and print the weekday
- C# program to design a simple calculator using if else if statements
- C# program to design a simple calculator using switch case statement
- Using string with switch case statement in C#
- C# program to demonstrate the use of a ternary conditional operator
Looping C# Programs
- C# program to print numbers from 1 to 15 using while loop
- C# | Print numbers from 1 to 15 using do while loop
- C# program to find out the prime numbers among 2 to 30
- C# program to find out the leap years from 1900 to 1950
- C# program to print Even and Odd numbers from 1 to 30
- Define Armstrong numbers and write program to check given number is Armstrong or not, in C#
- C# program to check whether a given number is Palindrome or not
- Define Fibonacci series - Write a program to print fibonacci series in c#
- C# program to find sum of all digits of a given number
- C# program to reverse digits of a given number
Array C# Programs
- C# | different types of one dimensional array declarations
- C# | printing an integer array using foreach loop
- C# | different types of two dimensional array declarations
- C# | Two dimensional array with fixed row size and variable columns size
- Find positive numbers from array of integers using C# program
- Find negative numbers from array of integers using C# program
- Find leap years form array of integers using C# program
- Print all Even numbers from array of integers using C# program
- Print all Odd numbers from array of integers using C# program
- Find largest element from an integer array in C#
- Find smallest element from integer array in C#
- Find palindrome numbers from array using C# program
- Insert an element at given position into array using C# program
- Delete an element from given position from array using C# program
- Reverse array elements using c# program
- Delete given element from array using C# program
- Find total number of occurrence of a given number using C# program
- Merge two arrays into third array using C# program
- C# program to make a simple ATM machine
- C# program to find the average of array elements
- C# program to convert a two-dimensional array into a one-dimensional array
- C# program to demonstrate the example of LongLength property of array
- C# program to print the lower bound and upper bound of an array
- C# program to find out the dimensions of an array
- C# program to demonstrate the example of BlockCopy method of the array
- C# program to produce a third array by appending two different arrays
- C# program to search an item in an array using binary search
- C# program to implement indexer for an integer array
- C# program to convert negative values an integer array into positive
- C# program to get the length of a jagged array using predefine property
- C# program to find the smallest and largest elements of an array using predefined methods
- C# program to find the average of array elements using the predefine Average() method of Queryable class
- C# program to find the sum of array elements using the predefine Sum() method of Queryable class
- C# program to reverse an integer array using a predefined method
- C# program to sort an integer array using the predefined method
- C# program to add two matrices
- C# program to transpose a matrix
- C# program to print the upper triangular matrix
- C# program to print the lower triangular matrix
- C# program to check the matrix is an identity matrix or not
- C# program to find the largest element in the matrix
- C# program to multiply two matrices
- C# program to find the sum of each row of the matrix
- C# program to find the sum of each column of the matrix
- C# program to find the sum of the right diagonal of the matrix
- C# program to find the sum of the left diagonal of the matrix
- C# program to interchange the columns of the matrix
- C# program for swapping of two arrays
- C# program to insert an item into a sorted array
- C# program to delete an item from a sorted array
Character Arrays C# Programs
- What is character array in C#, explain with an example?
- How to convert a string into character array in C#.Net?
- How to copy specified number of characters from a string into character array in C#?
- How to check whether string contains substring or not in C#?
Recursion C# Programs
- C# program to calculate the sum of all digits of a number using recursion
- C# program to print the binary equivalent of an integer number using recursion
- C# program to implement Power() method using recursion
String C# Programs
- Comparing two strings in C#
- Compare strings using Equals() method in c#
- Demonstrate the example of Copy method of String class in C#
- Demonstrate the example of IndexOf() method of string class in C#
- Explain LastIndexOf() method of String class with Example in C#
- Explain String.Split() method of String class in C# with an Example
- How to convert string into uppercase in C#?
- How to convert string into lowercase in C#?
- How to get substring from a string in C#?
- How to trim the string in C#, an example of String.Trim() method?
- How to trim leading spaces of string using String.TrimStart() in C#?
- How to trim trailing spaces of string using String.TrimEnd() in C#?
- How to pad string from left using String.PadLeft() in C#?
- How to pad string from right using String.PadRight() in C#?
- Check whether string ends with given substring or not using String.EndsWith() in C#?
- How to remove given substring from a string using String.Remove() in C#?
- How to replace a character with another character in a string in C#?
- C# program to count the frequency of the specified word in the given string
- C# program to trim a specified string
- C# program to trim a specified string from the left side
- C# program to trim a specified string from the right side
- C# program to split a string using the Split() method of String class
- C# program to extract only numbers from a specified string using the Split() method
- C# program to get the length of the string
- C# program to replace a substring within a specified string
- C# program to find the occurrence of the specified word in a given string
- C# program to convert a string from lowercase to uppercase
- C# program to print the abbreviation of a given string
- C# program to print the list of all possible substrings of a specified string
- C# program to count the total number of digits in an alpha-numeric string
- C# program to concatenate the two strings using a predefined method
- C# program to reverse a given string without using the predefined method
- C# program to perform left padding without using PadLeft() method
- C# program to perform the right padding without using the PadRight() method
- C# program to count the total number of vowels in a given string
- C# program to generate random strings
- C# program to encrypt and decrypt a string using Rijndael key algorithm
- C# program to count the lines in a given string
Class, Object, Methods C# Programs
- C# program to demonstrate the class and object creation
- 'this' reference in C#.Net with Example
- Explain Cascaded Method call in C# with an Example
- C# program for Default Arguments
- How to call non-trailing arguments as default argument in C#?
- How to pass object as argument into method in C#?
- Method returning object in C#
- C# program to demonstrate the example of a sealed class
- C# program to demonstrate the example of unboxing
- C# program to demonstrate the example of single inheritance
- C# program to demonstrate the example of multi-level inheritance
- C# program to demonstrate the example of hierarchical inheritance
- C# program to demonstrate the example of multilevel inheritance with method overriding
- C# program to demonstrate the simple interface
- C# program to implement the same method in multiple classes
- C# program to implement multiple interfaces in the same class
- C# program to implement multiple interfaces with the same method in the same class
- C# program to demonstrate interface implementation with multi-level inheritance
- C# program to implement an interface in a structure
- C# program to implement multiple-inheritance using the interface
- C# program to implement hierarchical inheritance using the interface
- C# program to demonstrate the inheritance of interfaces
- C# program to demonstrate the simple example of the abstract class
- C# program to implement the same abstract method in multiple classes
- C# program to inherit an abstract class and interface in the same class
- C# program to demonstrate abstract class with multiple-level inheritance
- C# program to implement multiple-inheritance using abstract class and interface
- C# program to implement hierarchical inheritance using the abstract class
- C# program to demonstrate the inheritance of abstract classes
- C# program to demonstrate the use of reflection to get namespace and base-type
- C# program to print class names created in the program using reflection
- C# program to print class names and its method names using reflection classes
- C# program to print method names and its parameters using reflection classes
- C# program to print constructors of the specified class using ConstructorInfo class
- C# program to print properties of the specified class using PropertyInfo class
- C# program to check a specified class is an abstract class or not
- C# program to check a specified class is a sealed class or not
- C# program to check a specified class is a serializable class or not
- C# program to check a class is a sub-class of a specified class or not
- C# program to check a specified type is a class or not
- C# program to check a specified type is an enum or not
- C# program to check a specified type is an interface or not
- C# program to check a specified type is nested or not
- C# program to check a specified type is a primitive data type or not
- C# program to check a specified type is a pointer or not
- C# program to check a specified type is an array or not
- C# program to check a specified type is public or not
- C# program to check a specified type is a value type or not
- C# program to print the current assembly name using GetExecutingAssembly() method
- C# program to demonstrate the interface
- C# program to demonstrate the properties in the interface
- C# program to demonstrate the IList interface
- C# program to demonstrate the IDictionary interface
- C# program to demonstrate the static class
- C# program to get the count of total created objects
- C# program to demonstrate the static constructor
- C# program to demonstrate the structure
- C# program to demonstrate the static constructor in the structure
- C# program to demonstrate the array of structures
- C# program to demonstrate the structure within a structure
- C# program to demonstrate method overloading based on the number of arguments
- C# program to demonstrate method overloading based on types of arguments
- C# program to demonstrate method overloading based on the order of arguments
- C# program to demonstrate the constructor overloading
- C# program to demonstrate the index overloading
- C# program to demonstrate the concept of method hiding
- C# program to demonstrate the example of anonymous method
- C# program to create an obsolete method in a class
- C# program to demonstrate the example of Pass by reference parameter passing in a method
Miscellaneous C# Programs
- C# program to demonstrate ATM transactions
- C# program to generate random numbers
- C# program to take height as input and print its category as Dwarf, Average, and Tall
- C# program to implement phonebook
- C# program to terminate the current running program explicitly
- C# program to create a user defined the namespace
- C# program to demonstrate the use of #define preprocessor
- C# program to demonstrate the example of regular expression
- C# program to demonstrate the example of Nullable data types
- C# program to print the hostname of the computer
- C# program to print the IP address of the computer
- C# program to demonstrate the validation of username and password
- C# program to demonstrate the conditional attribute using #define
- C# program to demonstrate the #if preprocessor directive
- C# program to demonstrate the #undef preprocessor directive
- C# program to demonstrate the #error preprocessor directive
- C# program to demonstrate the #warning preprocessor directive
- C# program to demonstrate the #region preprocessor directive
- C# program to demonstrate the #pragma preprocessor directive
- C# program to demonstrate the Obsolete attribute
- C# program to generate an error for the obsolete method using the Obsolete attribute
- C# program to demonstrate the CLSCompliant attribute
- C# program to demonstrate the Flags Attribute
- C# program to demonstrate unsafe code using pointers
- C# program to access array elements using the pointer
- C# program to swap two numbers using the pointer
- C# program to count vowels in character array using pointers
- C# program to demonstrate the pointer as a data member
- C# program to demonstrate the optional parameters
- C# program to demonstrate the named arguments
- C# program to demonstrate the command line arguments
- C# program to print pattern of 0's and 1's
- Explain StreamReader in C# with Example