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.

List of C# basic programs

Here is the list of some of the basic C# programs...

Basics

  1. C# program to print messages/text (program to print Hello world)
  2. C# program to demonstrate example of Console.Write() and Console.WriteLine()
  3. C# program to print a new line
  4. C# program to print backslash (\)
  5. C# program to demonstrate the example of New keyword
  6. C# program to print size of various data types
  7. C# program for type conversion from double to int
  8. C# program to convert various data type to string using ToString() method
  9. C# program to define various types of constants
  10. C# program to declare different types of variables, assign the values and print
  11. C# program to input and print an integer number
  12. C# program to demonstrate example of arithmetic operators
  13. C# program to demonstrate example of assignment operators
  14. C# program to demonstrate example of sizeof() operator
  15. C# program to demonstrate example of equal to and not equal to operators
  16. C# program to demonstrate example of relational operators
  17. C# program to demonstrate example of bitwise operators
  18. C# program to find the addition of two integer numbers
  19. C# program to swap two numbers with and without using third variable
  20. C# | print type, max and min value of various data types
  21. C# program to swap numbers using XOR operator
  22. C# program to find the magnitude of an integer number
  23. C# program to demonstrate the example of the left-shift operator
  24. C# program to demonstrate the example of the right shift operator
  25. C# program to read the grade of students and print the appropriate description of grade
  26. C# program to calculate the size of the area in square-feet based on specified length and width
  27. C# program to find the division of exponents of the same base
  28. C# program to demonstrate the example goto statement
  29. C# program to print a message without using the WriteLine() method
  30. C# program to convert a binary number into a decimal number
  31. C# program to convert a decimal number into a binary number
  32. C# program to convert a decimal number into an octal number
  33. C# program to convert a hexadecimal number into a decimal number
  34. C# program to convert a decimal number into a hexadecimal number
  35. C# program to convert a meter into kilo-meter and vice versa
  36. C# program to convert a temperature from Celsius to Fahrenheit
  37. C# program to convert a temperature from Fahrenheit into Celsius
  38. C# program to create gray code
  39. C# program to change the case of entered character
  40. C# program to convert entered days into years, weeks, and days
  41. C# program to convert the US dollar into Indian rupees
  42. C# program to print digits of a number into words
  43. C# program to check the given number is a perfect number or not
  44. C# program to print the all factors of a given number
  45. C# program to find the HCF of two given numbers
  46. C# program to check given numbers are the pair of amicable numbers or not
  47. C# program to find the addition of two complex numbers
  48. C# program to find the greatest common divisor (GCD)
  49. C# program to find the value of sin(x)
  50. C# program to demonstrate the trigonometry angles in degrees using Math class
  51. C# program to demonstrate the trigonometry angles in radians using Math class
  52. C# program to calculate the MEAN of a set of given numbers
  53. C# program to calculate the VARIANCE of a set of given numbers
  54. C# program to calculate the Standard Deviation of a set of given numbers
  55. C# program to calculate the compound interest
  56. C# program to calculate the Cosine(X) using a predefined method
  57. C# program to calculate the Cosine(X) without using a predefined method
  58. C# program to calculate the traveled distance based on speed and time
  59. C# program to print the Pascal Triangle
  60. C# program to calculate the sum of two binary numbers
  61. C# program to calculate the multiplication of two exponents of the same base
  62. C# program to print Floyd's triangle
  63. C# program to calculate the multiplication of two numbers using the left shift operator
  64. C# program to print the edge values using Pow() method
  65. C# program to calculate the fractional power of numbers
  66. C# program to demonstrate the bitwise operations
  67. C# program to find the root of a quadratic equation
  68. C# program to print the absolute value of a number without using Math.Abs() method
  69. C# program to find the Least Common Multiple of two numbers
  70. C# program to find the cube root of a given number
  71. C# program to find the square root of a given number without using Math.Sqrt() method
  72. C# program to calculate the area of a Cone
  73. C# program to calculate the volume of a cone
  74. C# program to calculate the NPR
  75. C# program to calculate the area of Sphere
  76. C# program to calculate the volume of Sphere
  77. C# program to calculate the perimeter of Circle
  78. C# program to calculate the perimeter of Rectangle
  79. C# program to calculate the NCR

If else (conditional statement) programs

  1. C# program to demonstrate example of simple if else statement
  2. C# program to demonstrate example of multiple if else statement
  3. C# program to demonstrate example of nested if else statement
  4. C# program to demonstrate example of conditional operator
  5. C# program to demonstrate example of nested conditional operator
  6. C# program to demonstrate example of switch statement
  7. C# program to demonstrate example of nested switch statement
  8. C# program to read two numbers and find maximum, minimum number
  9. C# program to find largest of two numbers
  10. C# program to find largest of three numbers
  11. C# program for character comparison
  12. C# program to check given strings are equal or not using equal to (==) operator
  13. C# program to input weekday number and print the weekday
  14. C# program to design a simple calculator using if else if statements
  15. C# program to design a simple calculator using switch case statement
  16. Using string with switch case statement in C#
  17. C# program to demonstrate the use of a ternary conditional operator


Looping programs

  1. C# program to print numbers from 1 to 15 using while loop
  2. C# | Print numbers from 1 to 15 using do while loop
  3. C# program to find out the prime numbers among 2 to 30
  4. C# program to find out the leap years from 1900 to 1950
  5. C# program to print Even and Odd numbers from 1 to 30
  6. Define Armstrong numbers and write program to check given number is Armstrong or not, in C#
  7. C# program to check whether a given number is Palindrome or not
  8. Define Fibonacci series - Write a program to print fibonacci series in c#
  9. C# program to find sum of all digits of a given number
  10. C# program to reverse digits of a given number

C# array programs

  1. C# | different types of one dimensional array declarations
  2. C# | printing an integer array using foreach loop
  3. C# | different types of two dimensional array declarations
  4. C# | Two dimensional array with fixed row size and variable columns size
  5. Find positive numbers from array of integers using C# program
  6. Find negative numbers from array of integers using C# program
  7. Find leap years form array of integers using C# program
  8. Print all Even numbers from array of integers using C# program
  9. Print all Odd numbers from array of integers using C# program
  10. Find largest element from an integer array in C#
  11. Find smallest element from integer array in C#
  12. Find palindrome numbers from array using C# program
  13. Insert an element at given position into array using C# program
  14. Delete an element from given position from array using C# program
  15. Reverse array elements using c# program
  16. Delete given element from array using C# program
  17. Find total number of occurrence of a given number using C# program
  18. Merge two arrays into third array using C# program
  19. C# program to make a simple ATM machine
  20. C# program to find the average of array elements
  21. C# program to convert a two-dimensional array into a one-dimensional array
  22. C# program to demonstrate the example of LongLength property of array
  23. C# program to print the lower bound and upper bound of an array
  24. C# program to find out the dimensions of an array
  25. C# program to demonstrate the example of BlockCopy method of the array
  26. C# program to produce a third array by appending two different arrays
  27. C# program to search an item in an array using binary search
  28. C# program to implement indexer for an integer array
  29. C# program to convert negative values an integer array into positive
  30. C# program to get the length of a jagged array using predefine property
  31. C# program to find the smallest and largest elements of an array using predefined methods
  32. C# program to find the average of array elements using the predefine Average() method of Queryable class
  33. C# program to find the sum of array elements using the predefine Sum() method of Queryable class
  34. C# program to reverse an integer array using a predefined method
  35. C# program to sort an integer array using the predefined method
  36. C# program to add two matrices
  37. C# program to transpose a matrix
  38. C# program to print the upper triangular matrix
  39. C# program to print the lower triangular matrix
  40. C# program to check the matrix is an identity matrix or not
  41. C# program to find the largest element in the matrix
  42. C# program to multiply two matrices
  43. C# program to find the sum of each row of the matrix
  44. C# program to find the sum of each column of the matrix
  45. C# program to find the sum of the right diagonal of the matrix
  46. C# program to find the sum of the left diagonal of the matrix
  47. C# program to interchange the columns of the matrix

C# Character Arrays programs

  1. What is character array in C#, explain with an example?
  2. How to convert a string into character array in C#.Net?
  3. How to copy specified number of characters from a string into character array in C#?
  4. How to check whether string contains substring or not in C#?

C# Recursion programs

  1. C# program to calculate the sum of all digits of a number using recursion
  2. C# program to print the binary equivalent of an integer number using recursion
  3. C# program to implement Power() method using recursion

C# String programs

  1. Comparing two strings in C#
  2. Compare strings using Equals() method in c#
  3. Demonstrate the example of Copy method of String class in C#
  4. Demonstrate the example of IndexOf() method of string class in C#
  5. Explain LastIndexOf() method of String class with Example in C#
  6. Explain String.Split() method of String class in C# with an Example
  7. How to convert string into uppercase in C#?
  8. How to convert string into lowercase in C#?
  9. How to get substring from a string in C#?
  10. How to trim the string in C#, an example of String.Trim() method?
  11. How to trim leading spaces of string using String.TrimStart() in C#?
  12. How to trim trailing spaces of string using String.TrimEnd() in C#?
  13. How to pad string from left using String.PadLeft() in C#?
  14. How to pad string from right using String.PadRight() in C#?
  15. Check whether string ends with given substring or not using String.EndsWith() in C#?
  16. How to remove given substring from a string using String.Remove() in C#?
  17. How to replace a character with another character in a string in C#?
  18. C# program to count the frequency of the specified word in the given string
  19. C# program to trim a specified string
  20. C# program to trim a specified string from the left side
  21. C# program to trim a specified string from the right side
  22. C# program to split a string using the Split() method of String class
  23. C# program to extract only numbers from a specified string using the Split() method
  24. C# program to get the length of the string
  25. C# program to replace a substring within a specified string
  26. C# program to find the occurrence of the specified word in a given string
  27. C# program to convert a string from lowercase to uppercase
  28. C# program to print the abbreviation of a given string
  29. C# program to print the list of all possible substrings of a specified string
  30. C# program to count the total number of digits in an alpha-numeric string
  31. C# program to concatenate the two strings using a predefined method
  32. C# program to reverse a given string without using the predefined method
  33. C# program to perform left padding without using PadLeft() method
  34. C# program to perform the right padding without using the PadRight() method
  35. C# program to count the total number of vowels in a given string
  36. C# program to generate random strings
  37. C# program to encrypt and decrypt a string using Rijndael key algorithm
  38. C# program to count the lines in a given string

C# Pattern printing programs

  1. C# program to print pattern of 0's and 1's

C# StreamReader/StreamWriter programs

  1. Explain StreamReader in C# with Example

Class, Object, Methods

  1. C# program to demonstrate the class and object creation
  2. 'this' reference in C#.Net with Example
  3. Explain Cascaded Method call in C# with an Example
  4. C# program for Default Arguments
  5. How to call non-trailing arguments as default argument in C#?
  6. How to pass object as argument into method in C#?
  7. Method returning object in C#
  8. C# program to demonstrate the example of a sealed class
  9. C# program to demonstrate the example of unboxing
  10. C# program to demonstrate the example of single inheritance
  11. C# program to demonstrate the example of multi-level inheritance
  12. C# program to demonstrate the example of hierarchical inheritance
  13. C# program to demonstrate the example of multilevel inheritance with method overriding
  14. C# program to demonstrate the simple interface
  15. C# program to implement the same method in multiple classes
  16. C# program to implement multiple interfaces in the same class
  17. C# program to implement multiple interfaces with the same method in the same class
  18. C# program to demonstrate interface implementation with multi-level inheritance
  19. C# program to implement an interface in a structure
  20. C# program to implement multiple-inheritance using the interface
  21. C# program to implement hierarchical inheritance using the interface
  22. C# program to demonstrate the inheritance of interfaces
  23. C# program to demonstrate the simple example of the abstract class
  24. C# program to implement the same abstract method in multiple classes
  25. C# program to inherit an abstract class and interface in the same class
  26. C# program to demonstrate abstract class with multiple-level inheritance
  27. C# program to implement multiple-inheritance using abstract class and interface
  28. C# program to implement hierarchical inheritance using the abstract class
  29. C# program to demonstrate the inheritance of abstract classes
  30. C# program to demonstrate the use of reflection to get namespace and base-type
  31. C# program to print class names created in the program using reflection
  32. C# program to print class names and its method names using reflection classes
  33. C# program to print method names and its parameters using reflection classes
  34. C# program to print constructors of the specified class using ConstructorInfo class
  35. C# program to print properties of the specified class using PropertyInfo class
  36. C# program to check a specified class is an abstract class or not
  37. C# program to check a specified class is a sealed class or not
  38. C# program to check a specified class is a serializable class or not
  39. C# program to check a class is a sub-class of a specified class or not
  40. C# program to check a specified type is a class or not
  41. C# program to check a specified type is an enum or not
  42. C# program to check a specified type is an interface or not
  43. C# program to check a specified type is nested or not
  44. C# program to check a specified type is a primitive data type or not
  45. C# program to check a specified type is a pointer or not
  46. C# program to check a specified type is an array or not
  47. C# program to check a specified type is public or not
  48. C# program to check a specified type is a value type or not
  49. C# program to print the current assembly name using GetExecutingAssembly() method
  50. C# program to demonstrate the interface
  51. C# program to demonstrate the properties in the interface
  52. C# program to demonstrate the IList interface
  53. C# program to demonstrate the IDictionary interface
  54. C# program to demonstrate the static class
  55. C# program to get the count of total created objects
  56. C# program to demonstrate the static constructor
  57. C# program to demonstrate the structure
  58. C# program to demonstrate the static constructor in the structure
  59. C# program to demonstrate the array of structures
  60. C# program to demonstrate the structure within a structure
  61. C# program to demonstrate method overloading based on the number of arguments
  62. C# program to demonstrate method overloading based on types of arguments
  63. C# program to demonstrate method overloading based on the order of arguments
  64. C# program to demonstrate the constructor overloading
  65. C# program to demonstrate the index overloading

Miscellaneous

  1. C# program to demonstrate ATM transactions
  2. C# program to generate random numbers
  3. C# program to take height as input and print its category as Dwarf, Average, and Tall
  4. C# program to implement phonebook
  5. C# program to terminate the current running program explicitly
  6. C# program to demonstrate the concept of method hiding
  7. C# program to demonstrate the example of anonymous method
  8. C# program to create an obsolete method in a class
  9. C# program to demonstrate the example of Pass by reference parameter passing in a method
  10. C# program to create a user defined the namespace
  11. C# program to demonstrate the use of #define preprocessor
  12. C# program to demonstrate the example of regular expression
  13. C# program to demonstrate the example of Nullable data types
  14. C# program to print the hostname of the computer
  15. C# program to print the IP address of the computer
  16. C# program to demonstrate the validation of username and password
  17. C# program to demonstrate the conditional attribute using #define
  18. C# program to demonstrate the #if preprocessor directive
  19. C# program to demonstrate the #undef preprocessor directive
  20. C# program to demonstrate the #error preprocessor directive
  21. C# program to demonstrate the #warning preprocessor directive
  22. C# program to demonstrate the #region preprocessor directive
  23. C# program to demonstrate the #pragma preprocessor directive
  24. C# program to demonstrate the Obsolete attribute
  25. C# program to generate an error for the obsolete method using the Obsolete attribute
  26. C# program to demonstrate the CLSCompliant attribute
  27. C# program to demonstrate the Flags Attribute
  28. C# program to demonstrate unsafe code using pointers
  29. C# program to access array elements using the pointer
  30. C# program to swap two numbers using the pointer
  31. C# program to count vowels in character array using pointers
  32. C# program to demonstrate the pointer as a data member
  33. C# program to demonstrate the Enum
  34. C# program to print the integer values of enum constants
  35. C# program to get the type-code of enum constants
  36. C# program to print the name of enum constant based on an integer value
  37. C# program to get the hash-code of enum constants
  38. C# program to demonstrate the optional parameters
  39. C# program to demonstrate the named arguments
  40. C# program to demonstrate the command line arguments





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.