C#

C# Practice Questions

Programmingempire

The following C# Practice Questions will help you learn the C# language.

C# Practice Questions – Basic Programs

Understanding the compilation and running of programs on VS.NET 2019.
Write a program that displays following: “A simple C# Program.”
Create a program that converts temperature specified in Celsius into Fahrenheit.
Write a program to compute area of a circle.
Also, Write a program to compute compound interest and total amount after specified number of years for given principal and rate of interest.
Write a program to find the roots of a quadratic equation.
Develop a program that computes the hypotenuse of a right triangle given the lengths of its two opposing sides.
Write a program to display the truth tables of 2-input gates: AND, OR, XOR.
Create a program to find largest of three numbers.
Write a program to display the marks in 3 subjects, total marks and percentage of each student of a class of 20 students with displaying 5 records per screen.
Given a number, write a program to reverse the digits of the number. Also display the sum of digits of the number.
Develop a program to find the prime numbers in a given range.
Write a program to display the following pattern on the screen.    
X
    X X X
  X X X X X
  X X X
      X    

C# Practice Questions – Programs on Logic Building

Create a program to demonstrate type conversion of incompatible types using type-casting.
Develop a Menu-Driven program to add, subtract, and divide and multiple 2 numbers.
Write program that randomly generates a number from a range 10-99 and checks whether it is Armstrong or not.
Create a program to initialize and print the elements of an array.
Write a program to find sum and average of n numbers stored in an array.
Develop a program to sort an array in ascending and descending order.
WAP to perform linear search on an Array of 5 integers.
Also, WAP to perform binary search on an Array of 5 integers.
How to to display smallest element of an Array of 5 integers?
WAP to display difference between smallest and largest elements of an Array of 5 integers.
Also, Write a program to find sum, difference and product of two matrices.
Create a program to find transpose of a matrix.
Write a program to calculate the standard deviation of an array of values. Use methods Standard and Mean to calculate standard deviation and mean of values.
Create a program to demonstrate the working of any Ten String class functions.
Develop a program to sort a list of strings.
WAP to extract surname from complete name
Write a program that accomplishes the following.
To delete an item in the list.
Add an item in the list at a specified location.
To add an item at the end of a list.
Print the contents of a list.
Write a program that takes two arrays as input and produces a third array by merging them.
Define a jagged array and write methods to input its elements and display.

C# Practice Questions – Programs on Arrays and Strings


Write a program to demonstrate the methods of Array class.
Create a program to demonstrate the methods of ArrayList class.
Write a program to perform following operations on strings.
Count the number of character.
Display the frequency of a character and a word.
Count the number of words
Find whether the string is palindrome or not.
Reverse the string
Write a program that creates a class Rectangle. Define overloaded constructors of this class. Display the area of a rectangle by calling the method of this class. Also write a method to scale the rectangle.
Write a program to demonstrate argument passing by using Call By Value and Call By Reference.
Develop a program to create a class Add that will add to numbers by using a default constructor.
Write a program to create a class called triangle with base and height as the attributes and calculate its area using parameterized constructor.
Create a program to demonstrate ref, out and params parameters.
Develop a program to create a class Area and calculate area of rectangle and circle using method overloading. Define a class factor that has a data member num.
Create a method to find all the factors of num and return these factors to the calling program.
Write a program to demonstrate sealed class and sealed function.
Develop a program to demonstrate static classes and static constructors.
Find the sum of two matrices using a C# program.
Write a program to demonstrate one-dimensional and multi-dimensional indexers.
How to use Computed Properties? Give an example.
Write a program that demonstrate following properties: Read-Write properties, Read-only properties, Write-only properties, Static properties

C# Practice Questions – Programs on Inheritance

Define an inner class inside another class with a method display(). The outer class contains a method show(). Create an object of both classes and call the methods display() and show().
Create a class Shape and derive two subclasses named Rectangle and Circle from the class Shape. Define overloaded constructors for all the classes.
Write a program to demonstrate the use of abstract class.
Demonstrate custom exception using a C# program.
Write a class called Date that includes data members day, month and year and methods that could implement the following tasks:
Read a date from keyboard
Display a dateIncrement a date by one day
Compare two dates to see which one is greater
Use operator overloading wherever applicable.
Also, Write a program to demonstrate exception handling
Design a structure type data using a suitable name for each of the following records.
A student record consisting of name, date of birth, and total marks obtained.
Mailing list consisting of name, door number, street, city, and pin code.
An inventory record consisting of item code, item name, item cost and the total items available.A book record consisting of the author, title, year of publication and cost.
Write separate program for each record structure to enter input values and display them in appropriate manner.
When should we use an abstract class? Demonstrate abstract class with an example.
Define an interface area with a method compute () to compute the area. Also, define two Classes Square and Circle that implement this interface. Write a program that instantiate the classes and call appropriate method.
Also, write a program to demonstrate single cast delegate.Write a program to demonstrate multi cast delegate and event handling using multicast delegate.
Give an example of a delegate.

Demonstrate the use of base keyword using a program in C#.
Write a program to demonstrate anonymous functions with delegates.
Develop a program to demonstrate the use of Lambda expressions.
Write a program to demonstrate ACTION and FUNC delegates.

C# Practice Questions – Programs on Collections

Demonstrate the methods of Array class using a program.
Write a program to display the list of integers and strings using IList.
How to use Object initializer in C#? Demonstrate with a program.
Write a program sort objects using IComparer.   
How to create generic Dictionary in C#?
Write a program to demonstrate IEnumerator and IEnumerable interface for forward and reverse iteration of a list of objects.
Create a program to demonstrate generic List, Dictionary, Stack and Queue.
Develop a Window Presentation Foundation (WPF) application.                              
Write a program for “Employee Detail management” using ADO.NET. the program should contain the following modules.
Add employee details.
Delete employee details.
Modify employee details.
Display employee list.Exit.
Further, Write a program to demonstrate LINQ queries with the following operations:
Filtering
Joining
Ordering
Grouping
How to find distinct elements from an array?
Write a program to read and write an XML document.

Further Reading

Selection Sort in C#

Insertion Sort in C#

Bubble Sort in C#

programmingempire

You may also like...