Kunal Kumar: 03911804413 MCA 3rd Sem
Kunal Kumar: 03911804413 MCA 3rd Sem
Kunal Kumar: 03911804413 MCA 3rd Sem
Net Programming
Kunal Kumar
03911804413
MCA 3rd sem
INDEX
S.NO.
TOPIC
DATE
SIGN
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");
}
}
}
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");
}
}
}
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].
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);
}
}
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();
}
}
LAB EXERCISE - 6
Ques. Write a program in C# to implement Delegates.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public delegate decimal Calculation(decimal a1, decimal a2);
namespace delegate1
{
class Program
{
static void Main(string[] args)
{
Calculation obj=new Calculation(add);
Console.WriteLine("Add Func "+obj(20.0m,22.0m));
obj=new Calculation(sub);
Console.WriteLine("Sub Func "+obj(20.0m,22.0m));
Console.ReadKey();
}
public static decimal add(decimal v1, decimal v2)
{
return v1 + v2;
}
public static decimal sub(decimal v1, decimal v2)
{
return v1 - v2;
}
}
}
{
index++;
if (index >= lbt.strings.Length)
return false;
else
return true;
}
public void Reset( )
{
index = -1;
}
// Current property defined as the
// last string added to the listbox
public object Current
{
get
{
return(lbt[index]);
}
}
}
// Enumerable classes can return an enumerator
public IEnumerator GetEnumerator( )
{
return (IEnumerator) new ListBoxEnumerator(this);
}
// initialize the list box with strings
public ListBoxTest(params string[] initialStrings)
{
// allocate space for the strings
strings = new String[8];
// copy the strings passed in to the constructor
foreach (string s in initialStrings)
{
strings[ctr++] = s;
}
}
// add a single string to the end of the list box
public void Add(string theString)
{
strings[ctr] = theString;
ctr++;
}
// allow array-like access
public string this[int index]
{
get
{
if (index < 0 || index >= strings.Length)
{
// handle bad index
}
return strings[index];
}
set
{
strings[index] = value;
}
}
// publish how many strings you hold
public int GetNumEntries( )
{
return ctr;
}
private string[] strings;
private int ctr = 0;
}
public class Tester
{
static void Main( )
{
// create a new list box and initialize
ListBoxTest lbt =
new ListBoxTest("Hello", "World");
// add a few strings
lbt.Add("Who");
lbt.Add("Is");
lbt.Add("smith");
lbt.Add("walker");
// test the access
string subst = "Universe";
lbt[1] = subst;
st.Pop();
Console.WriteLine("Current stack: ");
foreach (char c in st)
{
Console.Write(c + " ");
Console.ReadKey();
}
}
}
}
string1("CDAC");
}
}
LAB EXERCISE - 7
Ques. Convert an XML document to XSLT.
XML DOCUMENT
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="cdcatalog.xsl"?>
<catalog>
<cd country="USA">
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<price>10.95</price>
</cd>
<cd country="UK">
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<price>10.0</price>
</cd>
<cd country="USA">
<title>Greatest Hits</title>
<artist>Dolly Parton</artist>
<price>9.90</price>
</cd>
<cd country="USA">
<title>Empire Burlesque</title>
<artist>Ankit</artist>
<price>10.95</price>
</cd>
<cd country="India">
<title>Greatest Hits</title>
<artist>ABC</artist>
<price>8</price>
</cd>
</catalog>
XSLT
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<xsl:for-each select="catalog/cd">
<tr>
<td>TITLE: <xsl:value-of select="Name"/>
<br/>Artist:<xsl:value-of select="artist"/>
<br/>Price<xsl:value-of select="price"/>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
LAB EXERCISE - 8
Ques. Create a Windows Application Form.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace db1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void label2_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
label4.Visible = true;
if (textBox1.Text == "osama" && textBox2.Text == "abcde")
{
label4.Text = "Hello Osama ";
label4.ForeColor = Color.Green;
}
else
{
label4.Text = "Invalid Password";
label4.ForeColor = Color.Red;
}
}
}}