VISUAL PROGRAMMING and DOT NET TECHNOLOGIES LAB SYLLABUS
Implement the following programs on Windows pla orm using C# language.
  Prg. Division of
                                 List of Programs
  No. Programs
                                 Write a program in C# and display its metadata,
       Metadata
  1                              CIL, and manifest informa on using ildasm.exe
       Informa on
                                 tool.
                                 Write a program in CIL for custom constructor and
  2    Constructor
                                 sta c constructor using console applica on.
                                 Write a program in CIL to pass reference type by
  3    Reference Types
                                 value and reference type by reference.
                                 Write a program in C# to create custom
       Namespace and
  4                              namespaces. <br> Write a program in CIL to
       Inheritance
                                 demonstrate read only property.
                                 Write a program in C# to demonstrate hybrid
  5
                                 inheritance.
                                 Write a program in C# to demonstrate delegates.
       Delegates and
  6                              <br> Write a program in C# to demonstrate
       Interfaces
                                 interfaces.
       Array                     Write a program in C# to sort an array. <br> Write
  7
       Implementa on             a program in C# to create 2-D array.
       Lab Ques ons &
  8
       Assignments
    VISUAL PROGRAMMING and DOT NET TECHNOLOGIES LABORATORY
OBJECTIVE:
This course will cover the prac cal aspects of mul - er applica on
development using the .NET framework. The goal of this course is to introduce
the students to the basics of distributed applica on development. We will
introduce the students to Web Service development and .NET remo ng.
Technologies covered include the Common Language Run me (CLR), .NET 1
framework classes, and C#.
OUTCOMES:
Upon the comple on of Visual Programming and Dot Net Technologies
prac cal course, the student will be able to:
   1. Explain the role of basic components used in: .NET Framework- CLR, CTS,
      CLS & BCLS.
   2. Write, compile and debug C# program in Console (CSC.EXE) as well as in
      IDE (Visual Studio)
   3. Write, compile and debug object oriented program in C#.
   4. Write, compile and debug object oriented program using interfaces and
      collec ons.
   5. Design and develop small web applica ons/sites using ASP.NET
   6. Create & Deploy .NET assemblies (Private and Shared).
   7. Apply problem-solving techniques to solve real-world problems.
                             LIST OF PRACTICALS
Program 1. Write a program in C# and display its metadata, CIL, and manifest
informa on using ildasm.exe tool.
Program 2. Write a program in C# for custom constructor and sta c constructor
using console applica on.
Program 3. Write a program in C# to pass reference type by value and
reference type by reference.
Program 4. Write a program in C# to create custom namespaces.
Program 5. Write a program in C# to demonstrate read only property.
Program 6. Write a program in C# to demonstrate hybrid inheritance.
Program 7. Write a program in C# to demonstrate delegates.
Program 8. Write a program in C# to demonstrate interfaces.
Program 9. Write a program in C# to sort an array.
Program 10. Write a program in C# to create 2-D array.
                                          Prac cal-1
Aim: Write a Program in C# and display its Metadata, CIL, and Manifest informa on using ildasm.exe
tool.
Program:
C#
using System;
namespace ConsoleApplica on1
{
  class Program
  {
     sta c void Main(string[] args)
     {
       for (int i = 0; i < 10; i++)
       {
         for (int j = 0; j < i; j++)
         {
            Console.Write("*");
         }
         Console.WriteLine();
       }
       Console.ReadKey();
     }
  }
}
                                                     Prac cal-2
Aim: Write a program in C# for custom constructor and sta c constructor using console applica on.
Program:
C#
namespace ProgramCall
        class Test3
            public Test3()
                Console.WriteLine("Instance Constructor");
            sta c Test3()
                Console.WriteLine("Sta c Constructor");
        class Sta cConstructor
            sta c void Main()
                //Sta c Constructor and instance constructor, both are invoked for the first instance
                Test3 t1 = new Test3();
// Only instance constructor is invoked Test3
t2 = new Test3();
Console.ReadKey();
}
Output:
Sta c Constructor
Instance Constructor
Instance Constructor
                                                   Prac cal-3
Aim: Write a program to pass reference type by value and reference type by reference.
Program:
C#
using System;
namespace ReferenceType
    class Program
        sta c void Main(string[] args)
            // Create an array
            int[] array1 = { 1, 2, 3, 4, 5 };
            // Pass array by value (creates a copy)
            ChangeArray(array1);
            Console.WriteLine("A er passing by value: ");
            PrintArray(array1);
            // Pass array by reference (modifies original)
            ChangeArrayRef(ref array1);
            Console.WriteLine("A er passing by reference: ");
            PrintArray(array1);
            Console.ReadKey();
        sta c void ChangeArray(int[] arr)
            for (int i = 0; i < arr.Length; i++)
            {
                arr[i] = arr[i] * 2;
        sta c void ChangeArrayRef(ref int[] arr)
            for (int i = 0; i < arr.Length; i++)
                arr[i] = arr[i] * 3;
        sta c void PrintArray(int[] arr)
            foreach (int num in arr)
                Console.Write(num + " ");
            Console.WriteLine();
Output:
A er passing by value: 1 2 3 4 5
A er passing by reference: 3 6 9 12 15
                                                 Prac cal-4
Aim: Write a program in C# Language to create Custom Namespaces.
Program:
C#
using System;
using A.B.C;
using D;
namespace E
    using F;
    class Program
        sta c void Main(string[] args)
            // Can access CClass type directly from A.B.C
            CClass var1 = new CClass();
            // Can access DClass type from D
            DClass var2 = new DClass();
            // Must explicitly specify F namespace
            F.FClass var3 = new F.FClass();
            // Display types
            Console.WriteLine(var1);
            Console.WriteLine(var2);
            Console.WriteLine(var3);
            Console.ReadKey();
        }
    }
namespace A
    namespace B
        namespace C
            public class CClass
                 // ...
namespace D
    public class DClass
        // ...
namespace F
    public class FClass
        // ...
    }
}
Output:
A.B.C.CClass
D.DClass
F.FClass
                                              Prac cal-5
Aim: Write a Program in C# Language to demonstrate read only property and write only property.
Program:
C#
using System;
public class MyClass
    private int x;
    public int ReadOnlyProp { get; private set; } // Read-only property
    public int WriteOnlyProp
        set { x = value; }
    public MyClass(int n)
        x = n;
    public int Add()
        return x + 10;
class Test
    sta c void Main()
    {
        MyClass mc = new MyClass(5);
        mc.WriteOnlyProp = 10; // Set the value of the write-only property
        Console.WriteLine(mc.ReadOnlyProp); // Access the read-only property
        Console.WriteLine(mc.Add()); // Call the Add() method
        Console.ReadKey();
Output:
10
15
                                                     Prac cal-6
Aim: To write a program in C# Language to demonstrate Hybrid Inheritance.
Program:
C#
using System;
namespace ConsoleApplica on1
    class A
        public A()
            Console.WriteLine("This is class A.");
    class B : A
        public B()
            Console.WriteLine("This is class B.");
    class C : A
        public C()
            Console.WriteLine("This is class C.");
    }
    class D : B, C
        public D()
            Console.WriteLine("This is class D.");
class Program
    sta c void Main(string[] args)
        Console.WriteLine("Object of Class A created.");
        A a = new A();
        Console.WriteLine("\n\nObject of Class B created.");
        B b = new B();
        Console.WriteLine("\n\nObject of Class C created.");
        C c = new C();
        Console.WriteLine("\n\nObject of Class D created.");
        D d = new D();
        Console.ReadKey();
Output:
Object of Class A created.
This is class A.
Object of Class B created.
This is class A.
This is class B.
Object of Class C created.
This is class A.
This is class C.
Object of Class D created.
This is class A.
This is class B.
This is class D.
                                               Prac cal-7
Aim: Write a program in C# Language to demonstrate Delegates.
Program:
C#
using System;
namespace ConsoleApplica on5
    class Program
        public delegate void delmethod();
        public class P
            public sta c void display()
                Console.WriteLine("Hello!");
            public sta c void show()
                Console.WriteLine("Hi!");
            public void print()
                Console.WriteLine("Print");
        sta c void Main(string[] args)
        {
             // here we have assigned sta c method show() of class P to delegate delmethod()
             delmethod del1 = P.show;
      // here we have assigned sta c method display() of class P to delegate delmethod() using new
operator
             // you can use both ways to assign the delegate
             delmethod del2 = new delmethod(P.display);
             P obj = new P();
            // here first we have create instance of class P and assigned the method
// print() to the delegate i.e. delegate with class
delmethod del3 = obj.print;
del1();
del2();
del3();
Console.ReadLine();
Output:
Hi!
Hello!
Print
                                              Prac cal-8
8. Aim: Write a program in C# Language to demonstrate Interfaces inheritance.
Program:
C#
class Demo : abc
    public sta c void Main()
        System.Console.WriteLine("Hello Interfaces");
        Demo refDemo = new Demo();
        refDemo.xyz();
        Sample refSample = new Sample();
        refSample.xyz();
        System.Console.ReadKey();
    public void xyz()
        System.Console.WriteLine("In Demo:: xyz");
interface abc
    void xyz();
class Sample : abc
    public void xyz()
    {
        System.Console.WriteLine("In Sample xyz");
Output:
Hello Interfaces
In Demo:: xyz
In Sample xyz
                                                   Prac cal-9
Aim: Write a program of sor ng an array. Declare single dimensional array and accept 5 integer
values from the user. Then sort the input in ascending order and display output.
**using System;
namespace Example 1
class Program
sta c void printarray(int[] arr)
Console.WriteLine("\n\nElements of array are:");
foreach (int i in arr)
Console.Write(" {0}", i);
sta c void Main(string[] args)
        int[] arr = new int[5];
        // loop for accep ng values in array for
        for (int i = 0; i < 5; i++)
            Console.Write("Enter number: ");
            arr[i] = Convert.ToInt32(Console.ReadLine());
        Program.printarray(arr);
        // sor ng array value;
        Array.Sort(arr); // use array's sort func on
        Program.printarray(arr);
        Console.ReadLine();
Output
Enter number: 56
Enter number: 34
Enter number: 23
Enter number: 1
Enter number: 76
Elements of array are:
56 34 23 1 76
Elements of array are:
1 23 34 56 76