Você está na página 1de 7

List of C# Praticals

1.) Write a program in C# using command line arguments to display a welcome message. The
message has to be supplied as input in the command line
2.) Write a program in C# to find the area of a circle, given its radius.
3.) Write a program in C# to find the area of polygon triangle and rectangle by using
multiple constructors.
4.) Write a program in C# to add and multiply two numbers and display the results.
Demonstrate the use of ref and out parameters in this program.
5.) Using foreach looping statement, write a program in C# to display all the elements of string
array.
6.) Write a program in C# to create a string array to store 10 employees name. Display the
employees name to the console by passing array as a parameter to the display function.
7.) Write a program in C# to demonstrate the usage of checked and unchecked statements.
8.) Write a class called rectangle which consists of members side_1, side_2 and displayArea().
Write another class square which inherits class rectangle. Take side of square as input and
display the area of square on console.
9.) Write a program to sort 20 decimal numbers in decreasing order and print the result.
10.) Write a program for matrix multiplication in C#.
11.) Write a program in C# to sort the students list based on their names. The students list is
stored in a string array.
12.) Write a program in C# to demonstrate operator overloading
13.) Write a program in C# to demonstrate boxing and unboxing opertation.
14.) Write a program in C# to throw and catch any arithmetic exception.
15.) Write a program to demonstrate the usage of threads in C#.
16.) Write a program to demonstrate the usage of strings as array in C#.
17.) Write a program to demonstrate to show how to initialize data type in C#.
18.) Write a program to demonstrate termination execution and exit in C#.
19.) Write a program to Print Alphabets from ASCII Number in C#.
20.) Wap to use delegates
21.) Wap to show delegates types(lamda Expression/func/explicit delegates/action/predicate )
22.) Wap to show indexers
23.) Wap to show interfaces (expilicit interfaces with Properties)
24.) Wap to use ienumerable,ienumerate,icomparable,ilist .
25.) Wap to show generics (arraylists,hashtables,queue,stack,bitarray)
26.) Wap to show windows forms with controls (masked Textbox, richtext box,boxes
(listbox,checkedlistboxes,groupbox)
27.) Wap to use dialogboxes (open/save/print/font)
28.) Wap to use panels
29.) Wap to show one application on wpf
30.) Program that uses linq extension
31.) Program that uses query expression
32.) Program that show database connectivity
33.) Program to print pascal triangle?
34.) Wap to print the armstrong number?
35.) Wap to implement string using arrays?

List of C# Praticals

Question 36. Program to Print Pascal triangle?


Question 37. WAP to print the ARMSTRONG Number?
Question 38. WAP to implement String Using arrays?
Question 39. Lookup the System.DateTime structure. This type contains a large amount of
functionality that allows a user to perform all sorts of interesting operations with dates and times. Use
System.DateTime along with System.Console to implement a simple C# program that does the
following:
1. Ask the user for their birthday. It will probably easiest to ask year, then month, then day rather
than parsing a combined string reliably.
2. Calculate the age of the user.
3. Check to see if the age of the user is impossible. For example, if the user is not yet born, output
an error message. If the user claims to be 135 years old, then let them know that's not possible.
4. Output the age of the user to the console.
5. If it is the user's birthday, output a nice message.
6. Compute the user's astrological sign according to both the Western (sun sign) and Chinese
astrological systems. If you are not familiar with these astrological systems, look them up on the
web.
7. Output the computed signs to the console. Optionally output additional information (e.g.
horoscope of the day) about the user based on their sign.
Questions 40. Create a reference type called Person. Populate the Person class with the following
properties to store the following information:
1. First name
2. Last name
3. Email address
4. Date of birth
Add constructors that accept the following parameter lists:
1. All four parameters
2. First, Last, Email
3. First, Last, Date of birth
Add read-only properties that return the following computed information:
1. Adult - whether or not the person is over 18
2. Sun sign - the traditional western sun sign of this person
2

List of C# Praticals
3. Chinese sign - the chinese astrological sign (animal) of this person
4. Birthday - whether or not today is the person's birthday
5. Screen name - a default screen name that you might see being offered to a first time user of AOL
or Yahoo (e.g. John Doe born on Feburary 25th, 1980 might be jdoe225 or johndoe022580)
Question 41. Create an interface called Payable. This is the interface that will be used by the
accounting department's software (which you are not responsible for authoring) for all things that they
need to write checks for. ThePayable interface should contain three functions:
1. Retrieve amount due
2. Add to amount due
3. Payment address
Derive an Employee class from the Person class. The Employee class should add the following
properties:
1. Salary
2. Mailing address
In addition, the Employee class should implement the Payable interface. The implementation of the
functions specified in the Payable interface should make sense. In other words, the payment address
should be the mailing address of the employee. In order to make this work right, you will need to
allocate an internally protected state variable that keeps track of the amount of money due. This state
variable will obviously be modified by the functions defined in the interface. You can of course, try to
do this with a property and add this property to the Payable interface.
Question 42.WAP to implement SET,Get Properties?
Question8. Create a console application to calculate area of circle. Accept radius from user Calculate
circle area and print it
Create a console application to build simple calculator Calculator will have following functions Accept 2
numbers Perform Add/Sub/Div/Mult Print Result.
Question 43. Create a class Customer with following member fields
private int CustId, internal string CustName, public string CustNumber
Create an instance of Customer class and check accessibility of all fields
Add a static field int NoOfCustomers to Customer class
Create multiple instances of Customer class. On each new instance increment NoOfCustomers
by 1
Print NoOfCustomers
Make CustNumber field as Read only
Add a constant field string CompanyName to Customer class
Question 44. Create a class Customer with following member fields private int CustId, internal string
CustName, public string CustNumber
Add a static field int NoOfCustomers
Add a method PrintCustomer() to print customer details
Add PrintCustomer methods of different method signatures
3

List of C# Praticals
Add a static method PrintNoOfCustomers(). This method should print value of NoOfCustomers field
Question 45. Create a class Employee with fields protected int EmpId, protected string
EmpName,private EmpSalary Create a subclass Contractor for base class Employee. Define a
constructor for Contractor. Can you initialize all variables defined in the base class? Create instance of
subclass Contractor. Are base class constructors accessible? Invoke Contractor's constructor. Which all
constructors are getting invoked?
Define a field in Contractor matching its definition in the base class Employee. Is that allowed?
Question 46. Create a class Employee,Create a subclass Contractor for base class Employee
Seal Contractor class,Check if you are able to create sub class TempContractor for base class
Contractor?
Question 47. Create a class MyHelper static class
Add a static field int icount in MyHelper class
Add a static constructor to MyHelper class. Initialise icount to 10
Add a static method PrintCount in Myhelper class
Check if you are able to call MyHelper.PrintCount method from main method
Question 48. Create base class Customer and subclasses SilverCustomer and GoldCustomer
Define discount() method in Customer class whcih returns 20% discount
Overload discount method in the subclasses and return different discount value
Define base class variable as "Customer cust"
Assign different objects of Customer, SilverCustomer and GoldCustomer to variable cust one after other
and invoke discount method each time. What is the discount % returned each time?
Question 49. In the earlier assignment, how will you access the discount() method of Customer class
from SilverCustomer and GoldCustomer classes?
Question 50. Continue earlier assignment
Define another discount method in Customer class taking String location as parameter. Can it be
invoked?
Can this method be invoked from SilverCustomer or GoldCustomer classes?
Try to overload this discount(String) method in SilverCustomer class. Try to invoke it. Does the program
run?
Question 51. Continue earlier assignment:
Define a new method getCustomer. This should return instance of Customer or SilverCustomer or
GoldCustomer class randomly.
Main method will call getCustomer and then invoke the discount() method on the object received.
Execute and observe the results.
Now create a new PlatinumCustomer class extending Customer class. Implement discount() method in
this class
How do you invoke discount method of PlatinumCustomer class without changing main method?
Question 52: Create a class ContactDetails
Add private fields string stdcode, string city, string email
Add property StdCode with both get and set accessors defined.
In set accessor check if set stdcode is 020 if yes then set city = Pune else reject value
Add property City with only get accessor defined
Add property Email with both get and set accessors

List of C# Praticals
From Main method try setting property StdCode with value 020 check the value of property City
From Main method try setting property StdCode with value 023 check the value of property City.
Question 53. Create an array of integers
Sort the array using a standard sorting algorithm such as Bubble sort etc
Question 54. Create a class Customer
Add a property City
Create an array of type Customer
Print Customer details who are from Pune city
Question 55. Create a class Customer:
Add a property City
Create an array of type Customer
Print Customer details who are from Pune city
Question 56. Create a new interface BaseCalculator to develop a simple Calculator Define two methods
sum and divide in the interface. Can you implement the methods inside the interface? Create a new class
which implements above interface. Do you need to implement both the methods here? Now define one
more interface ScientificCalculator and add couple of methods Derive ScientificCalculator from
BaseCalculator interface
Create a class to implement ScientificCalculator interface, Check which methods needs to be
implemented in new class?
Question 57. Continue earlier assignment:
Define a variable whose type is an interface for the BaseCalculator,Assign an object of BaseCalculator
implementation,Invoke methods defined by the interface using the interface reference. Does the program
execute?
In class implementing BaseCalculator interface add a method,Check this method is accessible from
variable whose type is interface BaseCalculator.
Question 58. Continue earlier assignment
Create an interface AdvanceCalculator
Add couple of methods in this interface
Ensure that one of the method's signature is same as ScientificCalculator interface's method signature
Create a class implenting ScientificCalculator and AdvanceCalculator interfaces
Check what happens to method whose signature is common to ScientificCalculator and
AdvanceCalculator interfaces
Question 59. Define a method doCalc() in a class. It accepts an int parameter iVal
Perform following calculation "return 100/iVal;"
Invoke it from main method by passing zero value. What happens when you execute?
Introduce try-catch block around the method call. Which exception you need to catch for a meaningful
message?
Introduce a finally block after the catch block. When does it get called?
In the catch block make sure that you print the complete stack trace of error.
Write following code below the method call doCalc() "String str = argv[2];". Which exception is thrown

List of C# Praticals
on execution?
Handle the exception using another catch block.
Question 60. Continue earlier assignment
Immediately after the try block add a catch block without any exception type, do you get any error
during compilation time? If you remove the all catch blocks, do you get any error during compilation
time?
Question 61. Define a custom exception
Throw it using throw keyword Handle it in a catch block and examine various properties of exception
Question 62. Create a string
Assign it with large string value consisting of no of words
Access the string character by character and print
Access the string word by word and print
Split the string by using full stop character. Print the resultant strings.
Count no. of times a character has appeared in the string e.g. Char A - 132 times B - 50 times etc
Find a pattern in the string such as "AB" and replace it with some other string

List of C# Praticals
Question 63. Create a class Circle
Create an Enum Colors containng various color values such as GREEN/RED etc
Create a field CircleColor in Circle class which of type Enum colors
Create an instance of Circle class and set Color value to CircleColor
Print the Color value of CircleColor
Question 64. Create abstract class Car
Define an abstract method ignition()
Define a non-abstract/normal method changeGear(). Is this allowed?
Create concrete classe Sedan. Overload ignition method
Create instance of Sedan and invoke ignition() and changeGear() methods. Does the program execute?
Define a variable noOfWheels in Car class. Can it be accessed in Sedan class?
Question 65. Continue earlier assignment
Create an abstract class SUV extending Car class. Do you need to implement all abstract methods of Car
class here?
Define method 4WheelDrive() in SUV class
Create a concrete class Safari extending SUV class. Which methods must be implemented here?
Question 66. Create a class Magazine
Write a method Subscribe in Magazine class. This method should receive a delgate as parameter for call
back.
Write a method Publish(). This method should call all subscribed instances
Create a class Subscriber
Create a call back method ReceiveMagazine. This method should be used as call back method
Question 67. Create an instance of Magazine class
Create multiple instances of Subscriber class and subscribe with Magazine instance created
Call Publish() method of Magazine class and check if all subscribed instances are notified.

Você também pode gostar