C# Practical File
C# Practical File
Output: Hello
Practical 2:
Output: 11 22 33 44
Practical 3:
Output:
Practical 4:
Output:
Sum = 30
Product = 200
Practical 6:
Output:
Derived Display
Base Display
Practical 7:
Output:
Practical 8:
Output:
Division by zero
y=1
Practical 9:
using System;
using System.Collections.Generic;
class Program
{
static void Main()
{
int[] a = new int[3];
a[0] = 1;
a[1] = 2;
a[2] = 3;
Display(a);
Output:
Count: 3
123
Count: 3
579
Practical 10:
using System;
using System.Collections.Generic;
class Demo {
// Main Method
static public void Main () {
// Creating a dictionary
// using Dictionary<TKey,TValue> class
Dictionary<int, string> My_dict1 =
new Dictionary<int, string>();
// Adding key/value pairs
// in the Dictionary
// Using Add() method
My_dict1.Add(1123, "Welcome");
My_dict1.Add(1124, "to");
My_dict1.Add(1125, "Demo");
Foreach (KeyValuePair<int, string> ele1 in My_dict1)
{
Console.WriteLine("{0} and {1}",
ele1.Key, ele1.Value);
}
Console.WriteLine();
// Creating another dictionary
// using Dictionary<TKey,TValue> class
// adding key/value pairs without
// using Add method
Dictionary<string, string> My_dict2 =
new Dictionary<string, string>(){
{"a.1", "Dog"},
{"a.2", "Cat"},
{"a.3", "Pig"} };
Foreach (KeyValuePair<string, string> ele2 in My_dict2)
{
Console.WriteLine("{0} and {1}", ele2.Key, ele2.Value);
}
}
}
Output:
1123 and Welcome
1124 and to
1125 and Demo
a.1 and Dog
a.2 and Cat
a.3 and Pig
using System;
using System.Collections.Generic;
class Program
{
static void Main()
{
Dictionary<string, string> dict = new Dictionary<string, string>();
dict["Tom"] = "Bob";
WriteKeyA(dict);
SortedDictionary<string, string> sort = new SortedDictionary<string, string>();
sort["Tom"] = "Jerry";
WriteKeyA(sort);
Console.ReadLine();
}
Console.WriteLine(i["Tom"]);
}
}
Output:
Bob
Jerry
Index
S. No. ‘Name of the practical Page NO. Remarks
Constructors. 4
multiple interface. 5
(Teacher’s sign)
ACKNOWLEDGEMENT
I would like to express my special thanks of gratitude to
my respected Principal and my subject teacher “Mrs.
Rashmi Kuksal” for their guidance and support in
completing the practical file.
Secondly, I would also like to thank my parents and
friends who helped me a lot in finalizing this project
within the limited time frame.