C# Practice Questions


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

Understanding the compilation and running of programs on VS.NET 2019.
Write a program that displays following: “A simple C# Program.”
Write a program that converts temperature specified in Celsius into Fahrenheit.
Write a program to compute area of a circle.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.
Write 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.Write 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.
Write 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
Write a program to demonstrate type conversion of incompatible types using type-casting.
Write 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.
Write 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.
Write a program to sort an array in ascending and descending order.
WAP to perform linear search on an Array of 5 integers.WAP to perform binary search on an Array of 5 integers.
WAP 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.
Write a program to find sum, difference and product of two matrices.
Write 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.
Write a program to demonstrate the working of any Ten String class functions.
Write 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.
To add an item in the list at a specified location.
To add an item at the end of a list.
To 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.
Write a program to demonstrate the methods of Array class.
Write 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.
Write 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.
Write a program to demonstrate ref, out and params parameters.
Write 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.
Write a method to find the all the factors of num and return these factors to the calling program.
Write a program to demonstrate sealed class and sealed function.Write a program to demonstrate static classes and static constructors.
Write a program to demonstrate one-dimensional and multi-dimensional indexers.
Write a program that demonstrate following properties:Read-Write propertiesRead-only propertiesWrite-only propertiesStatic properties
Define an inner class inside another class with a method display(). Outer class contains a method show(). Create object of both classes and call the methods display() and show().
Define 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.
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.
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.
A 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.
Define an interface area with a method compute () to compute the area. Define two Classes Square and Circle that implement this interface. Write a program that instantiate the classes and call appropriate method.
Write a program to demonstrate single cast delegate.Write a program to demonstrate multi cast delegate and event handling using multicast delegate.
Write a program to demonstrate anonymous functions with delegates.
Write a program to demonstrate the use of Lambda expressions.
Write a program to demonstrate ACTION and FUNC delegates.
Write a program to display the list of integers and strings using IList.
Write a program sort objects using IComparer.   
Write a program to demonstrate IEnumerator and IEnumerable interface for forward and reverse iteration of a list of objects.
Write 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.
Write a program to demonstrate LINQ queries with the following operations:
Write a program to read and write an XML document.

Further Reading

Selection Sort in C#

Insertion Sort in C#

Bubble Sort in C#

How to Create Instance Variables and Class Variables in Python

Comparing Rows of Two Tables with ADO.NET

Example of Label and Textbox Control in ASP.NET

One Dimensional and Two Dimensuonal Indexers in C#

Private and Static Constructors in C#

Methods of Array Class

Anonymous Functions in C#

Programs to Find Armstrong Numbers in C#

Matrix Multiplication in C#

One Dimensional and Two Dimensional Indexers in C#

Static Class Example in C#

Rotating an Array in C#

Generic IList Interface and its Implementation in C#

Recursive Binary search in C#

C# Practice Questions

Creating Navigation Window Application Using WPF in C#

Find Intersection Using Arrays

An array of Objects and Object Initializer

Performing Set Operations in LINQ

Using Quantifiers in LINQ

Data Binding Using BulletedList Control

Grouping Queries in LINQ

Generic Binary Search in C#

Understanding the Quantifiers in LINQ

Join Operation using LINQ

Deferred Query Execution and Immediate Query Execution in LINQ

Examples of Query Operations using LINQ in C#

An array of Objects and Object Initializer

Language-Integrated Query (LINQ) in C#

How Data Binding Works in WPF

Examples of Connected and Disconnected Approach in ADO.NET

New Features in C# 9

IEnumerable and IEnumerator Interfaces

KeyValuePair and its Applications

C# Root Class – Object

Access Modifiers in C#

Learning Properties in C#

Learning All Class Members in C#

Examples of Extension Methods in C#

How to Setup a Connection with SQL Server Database in Visual Studio

Understanding the Concept of Nested Classes in C#

LINQ To SQL Examples

A Beginner’s Tutorial on WPF in C#

Explaining C# Records with Examples

Everything about Tuples in C# and When to Use?

Creating Jagged Arrays in C#

Linear Search and Binary search in C#

Learning Indexers in C#

Object Initializers in C#

Examples of Static Constructors in C#

When should We Use Private Constructors?

C# Basic Examples

IEqualityComparer Interface


You may also like...