C#

C# Practice Questions

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.

Basic Examples

  1. A Console Application in C# to display “Hello World”
  2. C# Program to perform temperature conversion
    1. Fahrenheit to Celsius
    2. Celsius to Fahrenheit
  3. 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.
  4. Find the roots of a quadratic equation using a C# Console Application. Further, the program should check all necessary conditions.

Conditional Statements and loops

  1. A C# program to find the largest of three numbers. As an illustration, make use of logical operators.
  2. Write a program in C# to display the table of a given number.
  3. Find the factorial of a number. Also, find the factorial using a recursive function.
  4. 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.
  5. 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.
  6. 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.
  7. 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.
  8. Create a C# Console Application using user-defined functions that takes an n-digit number and performs the following operations
    1. Count the number of digits
    2. Find the sum of digits
    3. Find reverse of digits
    4. Find whether a number is a palindrome

Arrays

  1. Write a program to perform a linear search and binary search on an array.
  2. Create a C# application to sort an array using bubble sort.
  3. 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.
  4. Define a jagged array and write methods to input its elements and display.
  5. Write a program in C# to perform the following operations on the matrix. Additionally, make use of user-defined functions.
    1. Addition
    2. Subtraction
    3. Transpose
  6. Write a program in C# to perform matrix multiplication with user-defined size for both matrices. Also, perform all necessary condition checking.
  7. Create a C# application that makes use of a user-defined function to return all factors of a number and displays them.

Classes and Objects

  1. Write a program in C# to display the count of the objects created. In particular, make use of overloaded constructors.
  2. 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.
  3. Create a C# application to swap two numbers using the ref keyword.
  4. 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.
  5. 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.

Constructors

  1. Create a class Person with overloaded constructors. Also, define its subclass Customer and demonstrate the use of base keyword for calling specific constructors.
  2. Write a program to demonstrate static classes. Also, demonstrate the use of static constructors.

Language Interoperability

  1. 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.

Operator Overloading

  1. Write a program for overloading following operators for the Complex class having two fields namely real and imaginary: +, -, *, ==, !=
  2. 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

Properties

  1. 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.
  2. 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.

Indexers

  1. Create a C# application to demonstrate one-dimensional and multi-dimensional indexers.

Exception Handling

  1. 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.

Structures

  1. Define a structure using a suitable name for each of the following records. Further, demonstrate the use of these structures.
    1. Student records consisting of name, date of birth, and total marks obtained.
    2. Mailing list consisting of name, door number, street, city, and pin code.
    3. An inventory record consisting of item code, item name, item cost, and the total items available.
    4. Book record consisting of the author, title, year of publication, and cost.

Inheritence and Access Modifiers

  1. Write a program to demonstrate different types of access modifiers available in C#.

Abstract Class

  1. 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

  1. Write a program that defines a class Shape. Also, define its subclasses Rectangle and Triangle and demonstrate dynamic binding.

Array and ArrayList Class

  1. Create a C# console application to demonstrate the methods of Array class.
  2. Write a program in C# to demonstrate the methods of the ArrayList class.
  3. 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).
  4. 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.

DateTime Struct

  1. Define a class to represent a Date containing data members: day, month, and year and methods that perform the following tasks:
    1. Read a date from the keyboard
    2. Display a date
    3. Increment a date by one day
    4. Compare two dates to see which one is greater

String Class

  1. Write a program to demonstrate the working of any Ten String class functions.
  2. Create an application to sort a list of strings.
  3. Write a program to perform the following operations on strings.
    1. Count the number of characters.
    2. Display the frequency of a character and a word.
    3. Count the number of words
    4. Find whether the string is palindrome or not.
    5. Reverse the string

Interface

  1. 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.

Delegates

  1. Write a program to demonstrate a single cast delegate.
  2. Demonstrate the use of a multicast delegate.
  3. Create a console application in C# to show event handling using user-defined events.
  4. Write a program to demonstrate anonymous functions with delegates.

Event Handling

  1. Define a class in C# for creating user-defined events. Also, demonstrate the use of this class.

Lambda Expressions

  1. Write a program to demonstrate the use of Lambda expressions.

ACTION and FUNC Delegate

  1. Demonstrate the use of ACTION and FUNC delegates in a C# application.

Collections

  1. Write a program to display the list of integers and strings using IList.
  2. Create a C# application to sort objects using IComparer.   
  3. Write a program to demonstrate generic List
  4. Create a C# application to demonstrate Dictionary
  5. Write a program in C# to demonstrate Stack
  6. Demonstrate the use of the Queue in a C# application.
  7. Write a program to demonstrate the IEnumerator and IEnumerable interface for forward and reverse iteration of a list of objects.

Window Forms Applications

  1. Create a Windows Forms Applications for creating a Login Form
  2. Demonstrate a Windows Forms Applications for creating a Registration Form for Student Admission.
  3. Create a Windows Form Applications for creating a Bus Pass
  4. Demonstrate a Windows Form Applications for creating a Purchase Order for an Item

Windows Presentation Foundation

  1. Develop a Window Presentation Foundation (WPF) application.

Database Connectivity with ADO.NET

  1. Write a program for “Employee Detail management” using ADO.NET. the program should contain the following features.
    1. Add employee details.
    2. Delete employee details.
    3. Modify employee details.
    4. Display employee list.
    5. Exit.
  2. Demonstrate the use of the disconnected approach of ADO.NET to display data from the Course table.

Language Integrated Query

  1. Write a program in C# to demonstrate LINQ queries with the following operations:
    1. Filtering
    2. Joining
    3. Ordering
    4. Grouping
  2. Create a C# application to demonstrate aggregate operators with LINQ.

LINQ to SQL

  1. Write a program in C# to execute LINQ to SQL Queries.

LINQ to XML

  1. Create a C# application to read and write an XML document.

Extension Methods

  1. Write a program in C# to define an extension method of String class.

Related Topics

How to Create a C# Console Application

C# Basic Examples, C# Examples, C# Arrays, Constructors in C#

Leave a Reply

Your email address will not be published. Required fields are marked *