In this post, you will find a list of C# Practice Questions. Here you will find a list of program statements on all important topics of C#.
List of C# Practice Questions
A topic-wise list of C# Practice Question is given below.
- A Console Application in C# to display “Hello World”
- C# Program to perform temperature conversion
- Fahrenheit to Celsius
- Celsius to Fahrenheit
- Write a program in C# to find (1) Area of Circle (2) Area of Triangle given its three sides. In addition, make use of user-defined functions.
- Find the roots of a quadratic equation using a C# Console Application. Further, the program should check all necessary conditions.
Conditional Statements and loops
- A C# program to find the largest of three numbers. As an illustration, make use of logical operators.
- Write a program in C# to display the table of a given number.
- Find the factorial of a number. Also, find the factorial using a recursive function.
- 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 6 records per screen.
- A C# console application that randomly generates a number from a range 10-999 and checks whether it is Armstrong or not. Also, define another function that displays all Armstrong numbers in the range 10-999.
- Find whether a number is prime or not using a user-defined function. Further, define another function that displays all the prime numbers in the given range on the console. Also, specify the upper limit of the range as a parameter. Finally, call both of these functions in the Main() method.
- Write a program in C# to calculate the standard deviation of an array of values. To point out, your program should have the user-defined methods named Standard and Mean to calculate standard deviation and mean of values.
- Create a C# Console Application using user-defined functions that takes an n-digit number and performs the following operations
- Write a program to perform a linear search and binary search on an array.
- Create a C# application to sort an array using bubble sort.
- Write a program in C#, that takes two arrays as input and produces a third array by merging them. To emphasize, write also the code for sorting input arrays before merging them.
- Define a jagged array and write methods to input its elements and display.
- Write a program in C# to perform the following operations on the matrix. Additionally, make use of user-defined functions.
- Write a program in C# to perform matrix multiplication with user-defined size for both matrices. Also, perform all necessary condition checking.
- Create a C# application that makes use of a user-defined function to return all factors of a number and displays them.
- Reversing Array in C#.
Classes and Objects
- Write a program in C# to display the count of the objects created. In particular, make use of overloaded constructors.
- Write a program in C# to display an array of objects created using the object-initializer syntax. In particular, define a class Box to create an array of objects.
- Create a C# application to swap two numbers using the ref keyword.
- Write a program to define a function for finding a minimum of any number of values that are not known in advance. In particular, make use of the params keyword.
- Define a class in C# to perform arithmetic operations on two numbers. However, define only one method to perform all operations and return all the resulting values. In particular, make use of the out keyword to achieve this.
- Create a class Person with overloaded constructors. Also, define its subclass Customer and demonstrate the use of base keyword for calling specific constructors.
- Write a program to demonstrate static classes. Also, demonstrate the use of static constructors.
- Create a ClassLibrary project in VB.NET that defines Person class. Further, create a Console Application in C# to define the subclass Student of Person class and display the value of all fields.
- Write a program for overloading following operators for the Complex class having two fields namely real and imaginary: +, -, *, ==, !=
- Write a program for overloading following relational operators for a class called Box: <, >, <=, >=, ==, !=. Also, define the appropriate constructors and a method to find the volume of the box along with three fields – width, height, and depth
- Create a C# application that defines a class Car with three fields: model, year and price. Also, define the corresponding property for each field. Finally, create the objects of this class and display them.
- Write a program that defines a class Student with the following fields: s_no, college_code, course_code, and year. In particular, s_no is a non-static field and other fields are static. Also, define a write-only property S_no that sets the value of s_no and define a read-only property Enrol that returns enrolment no. of a student. Finally, Display enrolment no. of 30 students.
- Write a program in C# to demonstrate exception handling. To emphasize, demonstrate the use of NullReferenceException, IndexOutofRangeException, and DivideByZeroException. Finally, show the usage of a custom exception also.
- Define a structure using a suitable name for each of the following records. Further, demonstrate the use of these structures.
- Student records 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.
- Book record consisting of the author, title, year of publication, and cost.
Inheritence and Access Modifiers
- Write a program to demonstrate different types of access modifiers available in C#.
- Create an abstract class called Shape and define its appropriate subclasses. Finally, demonstrate the instantiation of these classes in the Main() method.
Run Time Polymorphism
- Write a program that defines a class Shape. Also, define its subclasses Rectangle and Triangle and demonstrate dynamic binding.
Array and ArrayList Class
- Create a C# console application to demonstrate the methods of Array class.
- Write a program in C# to demonstrate the methods of the ArrayList class.
- Create an ArrayList by taking input from user. Now, Sort this list and then reverse it. Also, display Count and Capacity. Additionally, insert and remove elements at a specific position. Also, add another ArrayList (hint: use the AddRange method). Finally, display the complete list as well as a part of it (hint: use GetRange method).
- Write a program to create and display ArrayList of objects of Person class. The Person class has three fields: name, age, location. Also, the Person class has a parameterized constructor and ToString() method.
- Define a class to represent a Date containing data members: day, month, and year and methods that perform the following tasks:
- Write a program to demonstrate the working of any Ten String class functions.
- Create an application to sort a list of strings.
- Write a program to perform the following operations on strings.
- Define an interface area with a method compute () to compute the area. Also, define two Classes Square and Circle that implement this interface. Finally, write a program that instantiates the classes and call the appropriate method.
- Write a program to demonstrate a single cast delegate.
- Demonstrate the use of a multicast delegate.
- Create a console application in C# to show event handling using user-defined events.
- Write a program to demonstrate anonymous functions with delegates.
- Define a class in C# for creating user-defined events. Also, demonstrate the use of this class.
ACTION and FUNC Delegate
- Write a program to display the list of integers and strings using IList.
- Create a C# application to sort objects using IComparer.
- Write a program to demonstrate generic List
- Create a C# application to demonstrate Dictionary
- Write a program Demonstrating an Example of Using a Generic Dictionary in C#.
- Write a program in C# to demonstrate Generic Stack
- Demonstrate the use of the Generic Queue in a C# application.
- Write a program to demonstrate the IEnumerator and IEnumerable interface for forward and reverse iteration of a list of objects.
- Write An Example Demonstrating How to Create a Generic Class in C#
- Write a program to demonstrate how to implement the IList interface.
Window Forms Applications
- Create a Windows Forms Applications for creating a Login Form
- Demonstrate Windows Forms Applications for creating a Registration Form for Student Admission.
- Create a Windows Form Applications for creating a Bus Pass
- Demonstrate a Windows Form Applications for creating a Purchase Order for an Item
Windows Presentation Foundation
- Develop a Window Presentation Foundation (WPF) application.
Database Connectivity with ADO.NET
- Write a program for “Employee Detail management” using ADO.NET. the program should contain the following features.
- Add employee details.
- Delete employee details.
- Modify employee details.
- Display employee list.
- Demonstrate the use of the disconnected approach of ADO.NET to display data from the Course table.
- Program demonstrating how to write queries using an array as the data source in LINQ.
- Write a program in C# to demonstrate LINQ queries with the following operations:
- Create a C# application to demonstrate aggregate operators with LINQ.
- Example of Group By Queries in LINQ
LINQ to SQL
LINQ to XML
- Create a C# application to read and write an XML document.