Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
100 views

Lab Exercise:-1: Ques. Develop An Exe With Visual Studio

The document contains summaries of 5 lab exercises: 1. Developing an executable file in Visual Studio that prints a message. 2. Developing a private DLL in Visual Studio with a class and method to display a message. This DLL is used in a separate application. 3. Developing a shared DLL with a strong name key file. 4. Compiling a program written in Notepad using the CSC compiler. 5. Creating an abstract Shape class with fields for dimensions and an abstract Area method. Inheriting this class for Circle, Square, Rectangle classes to calculate their areas. Developing the program in ASP.NET with inputs and outputs.

Uploaded by

kuku288
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
100 views

Lab Exercise:-1: Ques. Develop An Exe With Visual Studio

The document contains summaries of 5 lab exercises: 1. Developing an executable file in Visual Studio that prints a message. 2. Developing a private DLL in Visual Studio with a class and method to display a message. This DLL is used in a separate application. 3. Developing a shared DLL with a strong name key file. 4. Compiling a program written in Notepad using the CSC compiler. 5. Creating an abstract Shape class with fields for dimensions and an abstract Area method. Inheriting this class for Circle, Square, Rectangle classes to calculate their areas. Developing the program in ASP.NET with inputs and outputs.

Uploaded by

kuku288
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Lab Exercise :- 1

Ques. Develop an exe with Visual Studio.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace proj3
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("This is the simple executable File ");
Console.ReadKey();
}
}
}

Lab Exercise :- 2
Ques. Develop a private dll with Visual Studio.
using
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;
System.Threading.Tasks;

namespace MyLib1
{
public class MyClass
{
public static void display(String s)
{
Console.WriteLine("Hello .."+s+"This is the Display Function of MyClass of MyLib1.dll");
}
}
}

Use the created dll classes in our file


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace console
{
class Program
{
static void Main(string[] args)
{
MyLib1.MyClass.display("KuKu");
Console.WriteLine("Main Exited");
}
}}

Lab Exercise :- 3
Ques. Develop shared dll using Visual Studio.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
[assembly: AssemblyKeyFile("D:\\programs\\Dot Net\\key1.snk")]
namespace MyLib1
{
public class MyClass
{
public static void display(String s)
{
Console.WriteLine("Hello .."+s+"This is the Display Function of MyClass of MyLib1.dll");
}
}
}

Key is created for strong name of MyLib1.dll

Lab Exercise :- 4
Ques. Write a program in notepad and compile it using CSC compiler.

using System;
namespace Outer
{
public class MyClass
{
static void Main()
{Console.WriteLine("Main Method of My Class");}
}

LAB EXERCISE-5
Ques. Create an abstract class shape with length, width, height and radius as fields and Area() as
abstract function and inherited it for Circle, Square and Rectangle class.
[Develop this program in ASP.NET with good look and feel. Use Images wherever required].

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master"


AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<Table Border="2" width="700Px">
<tr>
<td class="style1"><asp:Image runat="server" ID="ImgCircle" ImageUrl="~/circle.jpg">
</asp:Image> </td>
<td><asp:Label runat="server" ID="LabRadius" Text="Radius"></asp:Label></td>
<td><asp:TextBox runat="server" ID="TxtRadius"></asp:TextBox></td>
<td>Area:<asp:Label runat="server" ID="LabCircleArea"></asp:Label></td>
<td><asp:Label ID="area1" runat="server" Text=""></asp:Label></td>
</tr>
<tr>
<td class="style1"><asp:Image runat="server" ID="ImgSquare" ImageUrl="~/square.png">
</asp:Image> </td>
<td><asp:Label runat="server" ID="LabSize" Text="Size"></asp:Label></td>
<td><asp:TextBox runat="server" ID="TxtSize"></asp:TextBox></td>
<td>Area:<asp:Label runat="server" ID="LabSquareArea"></asp:Label></td>
<td><asp:Label ID="area2" runat="server" Text=""></asp:Label></td>
</tr>
<tr>
<td class="style1"><asp:Image runat="server" ID="Image1" ImageUrl="~/rectangle.png">
</asp:Image> </td>
<td><asp:Label runat="server" ID="LabLength" Text="Length"></asp:Label><br/>
<asp:Label runat="server" ID="LabWidth" Text="Width"></asp:Label>
</td>
<td><asp:TextBox runat="server" ID="TxtLength"></asp:TextBox><br/>
<asp:TextBox runat="server" ID="TxtWidth"></asp:TextBox>
</td>
<td>Area:<asp:Label runat="server" ID="LabRectArea"></asp:Label></td>
<td><asp:Label ID="area3" runat="server" Text=""></asp:Label></td>
</tr>
<tr><td align="center" colspan="4"><asp:Button runat="server" ID="BtnSubmit"
Text="Submit" onclick="BtnSubmit_Click"> </asp:Button>
</td>
</tr>
</Table>

</asp:Content>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication1
{
public abstract class Shape
{
protected float length;
protected float width;
protected float height;
protected float radius;
abstract public float area();
}
class Circle : Shape
{
public Circle(float r)
{
radius = r;
}
public override float area()
{
return (3.14f * radius * radius);
}
}
class Square : Shape
{
public Square(float h)
{
height = h;
}
public override float area()
{
return (height * height);
}
}
class Rectangle : Shape
{
public Rectangle(float l, float w)
{
length = l;
width = w;

}
public override float area()
{
return (length * width);
}
}
public partial class _Default : System.Web.UI.Page
{
protected void BtnSubmit_Click(object sender, EventArgs e)
{
if ((TxtRadius.Text) != "")
{
float r = (float)Convert.ToDecimal(TxtRadius.Text);
Circle cobj = new Circle(r);
area1.Text = Convert.ToString(cobj.area());
}
if ((TxtSize.Text) != "")
{
float s = (float)Convert.ToDecimal(TxtSize.Text);
Square sobj = new Square(s);
area2.Text = Convert.ToString(sobj.area());
}
if ((TxtLength.Text) != "" && (TxtRadius.Text) != "")
{
float l = (float)Convert.ToDecimal(TxtLength.Text);
float b = (float)Convert.ToDecimal(TxtWidth.Text);
Rectangle robj = new Rectangle(l, b);
area3.Text = Convert.ToString(robj.area());
} } } }

Ques. Demonstrate the Explicit Interface Implementation by creating two or more interfaces that
have same signatures.
using System;
interface Italk1
{
void Read();
}
interface Italk2
{
void Read();
}
class Derived1:Italk1,Italk2
{
void Italk1.Read()
{
Console.WriteLine("Reading from First Interface");
}
void Italk2.Read()
{
Console.WriteLine("Reading from Second Interface");
}
public static void Main(string[] args)
{
Derived dobj=new Derived();

Italk1 o1=(Italk1)dobj;
Italk2 o2=(Italk2)dobj;
o1.Read();
o2.Read();
Console.ReadKey();
}
}

Ques. Demonstrate the Explicit Interface Implementation by creating two or more interface that
have same signatures with Operator AS.
using System;
interface Italk1
{
void Read();
}
interface Italk2
{
void Read();
}
class Derived:Italk1,Italk2
{
void Italk1.Read()
{
Console.WriteLine("Reading from First interface");
}
void Italk2.Read()
{
Console.WriteLine("Reading from Second Interface");
}
public static void Main(string[] args)
{
Derived1 dobj=new Derived1();
Italk1 o1=dobj as Italk1;

Italk2 o2=dobj as Italk2;


o1.Read();
o2.Read();
Console.ReadKey();
}
}

You might also like