C# is a modern, object-oriented, general-purpose programming language that is easy to learn and use. C# is syntactically similar to Java and is simple to learn for users who are already familiar with C, C++, or Java. The main features of the C# language are modern, simple, fast, open-source, cross-platform, secure, versatile, and most widely used in mobile and web applications, web services, websites, games, and databases. This section contains many examples of C# programming, from simple programs to complex and advanced C# programs.
These examples range from basic C# programs to mathematical functions, data types, operators, arrays, matrix, strings, preprocessor attributes, LINQ, functions, delegates, inheritance, file handling, event handling, exception handling, networking, interfaces, threads, and games. Every example program includes the problem description, problem solution, source code, program explanation, and run-time test cases. All C# examples have been compiled and tested on Visual Studio.
- C# Basic Programs
- C# Programs on Data Types & Operators
- C# Programs on Numbers
- C# Programs on Date, Time & Year
- Special C# Programs
- Conversion Programs in C#
- Pattern Programs in C#
- C# Programs on Math Functions
- C# Programs on GCD, LCM & HCF
- C# Programs on Bitwise Operations
- C# Programs on Array
- C# Programs on Matrix
- C# Programs on Strings
- C# Programs on Sorting
- C# Programs on Preprocessor Attributes
- Data Structures & Algorithms in C#
- C# Programs on LINQ
- C# Programs on Functions
- C# Programs on Delegates
- C# Programs on Inheritance
- C# Programs on Operator Overloading
- C# Programs on File Handling
- C# Programs on Event Handling
- C# Programs on Exception Handling
- C# Programs on Networking
- C# Programs on Interfaces
- C# Programs on Threads
- C# Programs on Gaming
- C# Programs on Misc
C# Basic Programs
- C# Program to Check Whether a Given Number is Even or Odd
- C# Program to Print Odd Numbers in a Given Range
- C# Program to Check Whether a Number is Positive or Not
- C# Program to Find the Largest of Two Numbers
- C# Program to Swap Two Numbers
- C# Program to Check if a Number is Divisible by 2
- C# Program to Find the Sum of All the Multiples of 3 and 5
- C# Program to Print All the Multiples of 17 which are Less than 100
- C# Program to Find Sum of Digits of a Number
- C# Program to Find Sum of Digits of a Number using Recursion
- C# Program to Reverse a Number
- C# Program to Reverse a Number and Check if it is a Palindrome
- C# Program to Find the Sum of Two Binary Numbers
- C# Program to Multiply Two Binary Numbers
- C# Program to Calculate the Sum, Multiplication, Division and Subtraction of Two Numbers
- C# Program to Perform Multiplication of Exponents of Same Base
- C# Program to Find the Division of Exponents of Same Base
- C# Program to Print Binary Equivalent of an Integer using Recursion
- C# Program to Print Multiplication Table
- C# Program to Read a Grade and Display the Equivalent Description
- C# Program to Convert Lowercase Characters by Uppercase and Vice-Versa
- C# Program to Accept the Height of a Person and Categorize as Taller, Dwarf & Average
C# Programs on Data Types & Operators
- C# Program to Find the Minimum Range of Data Types
- C# Program to Find the Maximum Range of Data Types
- C# Program to Perform All Arithmetic Operations
- C# Program to Demonstrate the use of Conditional Logical Operator
- C# Program to Demonstrate Boxing Operations
- C# Program to Perform Unboxing Operation
C# Programs on Numbers
- C# Program to Generate Fibonacci Series
- C# Program to Print the Factorial of a Given Number
- C# Program to Print All the Prime Numbers between 1 to 100
- C# Program to Find the Largest Prime Factor of a Number
- C# Program to Check Whether a Given Number is Perfect Number
- C# Program to Check Armstrong Number
- C# Program to Print Armstrong Number between 1 to 1000
- C# Program to Generate the Sum of N Numbers
- C# Program to Find the Sum of First 50 Natural Numbers using For Loop
- C# Program to Find the Factors of the Given Number
- C# Program to Print the Absolute Value of a Number
- C# Program to Generate Random Numbers
- C# Program to Check Whether the Given Number is a Amicable Number or Not
- C# Program to Find Square Root of a Number
- C# Program to Find the Cube Root of a Number
- C# Program to Add Two Complex Numbers
- C# Program to Calculate Fractional Power
- C# Program to Calculate Power of Three
- C# Program to Print the Edge Values in Power Function
- C# Program to Find Product of Two Numbers using Recursion
- C# Program to Reverse a Number
- C# Program to Generate Register Number Automatically for 100 Students using Static Constructor
- C# Program to Generate the Marksheet of the Student
C# Programs on Date, Time & Year
- C# Program to Get the Local Time
- C# Program to Get the Universal Time
- C# Program to Display the Date in Various Formats
- C# Program to Add Two Dates
- C# Program to Compare Two Dates
- C# Program to Check if a Given Year is a Leap Year
- C# Program to Convert Days into Years, Months and Days
- C# Program to Get the DayLight Saving Information
Special C# Programs
- C# Program to Print Hello World Without using WriteLine
- C# Program to Display the ATM Transaction
- C# Program to Get IP Address
- C# Program to Illustrate how User Authentication is Done
- C# Program to Implement PhoneBook
- C# Program to Create a Stop Watch
- C# Program to Generate the Marksheet of the Student
Conversion Programs in C#
- C# Program to Convert Binary to Decimal
- C# Program to Convert Decimal to Binary
- C# Program to Convert Decimal to Hexadecimal
- C# Program to Convert Decimal to Octal
- C# Program to Convert Hexadecimal to Decimal
- C# Program to Create a Gray Code
- C# Program to Convert Celsius to Fahrenheit
- C# Program to Convert Fahrenheit to Celsius
- C# Program to Perform Currency Conversions
- C# Program to Convert Digits to Words
- C# Program to Convert Meter to Kilometer and Viceversa
- C# Program to Convert Big Endian to Little Endian
C# Programs on Math Functions
- C# Program to Find Simple Interest
- C# Program to Find Compound Interest
- C# Program to Calculate the Value of cos(x)
- C# Program to Calculate the Value of cos(x)
- C# Program to Demonstrate Trigonometry Angles in Degrees
- C# Program to Demonstrate Trigonometry Angles in Radians
- C# Program to Find the Roots of a Quadratic Equation
- C# Program to Calculate the Series sin(x)=x-x^3/3!+x^5/!-x^7/7!+……
- C# Program to Find Volume and Surface Area of Cone
- C# Program to Find Volume and Surface Area of Sphere
- C# Program to Find the Perimeter of Circle and Rectangle
- C# Program to Find the Value of 1/(1+x2) using Simpson’s 1/3 Rule
- C# Program to Display Squarefeet of a House
- C# Program to Calculate Acceleration
- C# Program to Count the Number of 1’s in the Entered Number
- C# Program to Find nCr
- C# Program to Find nPr
- C# Program to Find a Number using Pythagoras Theorem
- C# Program to Find the Mean
- C# Program to Find the Standard Deviation
- C# Program to Calculate Period Duration
- C# Program to Calculate Distance, Speed and Time
C# Programs on Bitwise Operations
- C# Program to Demonstrate Bitwise Operators
- C# Program to Multiply Number by 4 using Bitwise Operators
- C# Program to Find Whether a Given Number is Power of 2 using Bitwise Operators
- C# Program to Check whether the Given Integer has an Alternate Pattern
- C# Program to Swap Two Numbers using Bitwise XOR Operation
- C# Program to Demonstrate LeftShift Operations
C# Programs on Array
C# Programs on Matrix
- C# Program to Find the Smallest Element in a Matrix
- C# Program to Find the Largest Element in a Matrix
- C# Program to Add Two Matrices
- C# Program to Subtract Two Matrices
- C# Program to Multiply Two Matrices
- C# Program to Display Lower Triangular Matrix
- C# Program to Display Upper Triangular Matrix
- C# Program to Find Transpose of a Matrix
- C# Program to Check if Two Matrices are Equal
- C# Program to Check if a Matrix is an Identity Matrix
- C# Program to Find Sum of Diagonal Elements of Matrix
- 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 Interchange the Rows of a Matrix
- C# Program to Interchange the Columns of a Matrix
C# Programs on Strings
- C# Program to Concatenate Two Strings
- C# Program to Convert Upper case to Lower Case
- C# Program to Convert Characters of a String to Opposite Case
- C# Program to Perform Searching using Predefined Functions
- C# Program to Trim the Given String
- C# Program to Find the Length of a String
- C# Program to Find All Substrings in a String
- C# Program to Encrypt/Decrypt a String using Rijndael Key
C# Programs on Sorting
- C# Program to Implement Insertion Sort
- C# Program to Implement Selection Sort
- C# Program to Implement Bubble Sort
- C# Program to Implement Merge Sort
- C# Program to Implement Quick sort
- C# Program to Implement Heap sort
- C# Program to Implement Sequential Sort
- C# Program to Implement Radix Sort
- C# Program to Sort a List of Names in Alphabetical Order
- C# Program to Sort a String using Predefined Function
C# Programs on Preprocessor Attributes
- C# Program to Demonstrate the use of #define Preprocessor
- C# Program to Demonstrate Pass by Value
- C# Program to Demonstrate Pass by Reference
- C# Program to Demonstrate the Difference between Value Type Parameter and Reference Type Parameter
- C# Program to Illustrate Regular Expression Pattern
- C# Program to Implement Namespaces
- C# Program to Demonstrate the Goto Statement
Data Structures & Algorithms in C#
- C# Program to Traverse the Singly Linked List
- C# Program to Demonstrate Circular Single Linked List
- C# Program to Implement a Binary Search Tree using Linked List
- C# Program to Implement Stack with Push and Pop operations
- C# Program to Convert Infix to Postfix
- C# Program to Illustrate Dining Philosopher Problem
C# Programs on LINQ
- C# Program to Generate Odd Numbers in Parallel using LINQ
- C# Program to Calculate the Size of File using LINQ
- C# Program to Count File Extensions and Group it using LINQ
- C# Program to Display the Student Details using Select Clause LINQ
- C# Program to Display the Greatest Numbers in an Array using WHERE Clause LINQ
C# Programs on Functions
C# Programs on Delegates
C# Programs on Inheritance
- C# Program to Demonstrate Single Inheritance
- C# Program to Demonstrate Multilevel Inheritance
- C# Program to Demonstrate Hierarchical Inheritance
- C# Program to Demonstrate Multilevel Inheritance with Virtual Methods
- C# Program to Display Cost of a Rectangle Plot Using Inheritance
- C# Program to Demonstrate the Overriding
C# Programs on File Handling
C# Programs on Event Handling
C# Programs on Exception Handling
- C# Program to Demonstrate Stack Overflow Exception
- C# Program to Demonstrate Multiple Exceptions
- C# Program to Demonstrate IndexOutOfRange Exception
- C# Program to Demonstrate DivideByZero Exception
- C# Program to Demonstrate NullReference Exception
- C# Program to Demonstrate Exception Handling for Invalid TypeCasting in UnBoxing