Adding reference of ClassLibrary to a project:
Problem 1:-->
Windowform1:
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ClassLibrary1;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public
Form1()
{
InitializeComponent();
}
Class1
obj = new Class1();
private
void button1_Click(object
sender, EventArgs e)
{
double
x;
double
y;
x = double.Parse(textBox1.Text);
y = double.Parse(textBox2.Text);
label3.Text=(obj.add(x,
y).ToString());
}
private
void button2_Click(object
sender, EventArgs e)
{
double
x = double.Parse(textBox1.Text);
double
y = double.Parse(textBox2.Text);
label3.Text=(obj.sub(x,
y).ToString());
}
private
void button3_Click(object
sender, EventArgs e)
{
double
x = double.Parse(textBox1.Text);
double
y = double.Parse(textBox2.Text);
label3.Text=(obj.mul(x,
y).ToString());
}
private
void button4_Click(object
sender, EventArgs e)
{
double
x = double.Parse(textBox1.Text);
double
y = double.Parse(textBox2.Text);
label3.Text=(obj.div(x,
y).ToString());
}
private
void label3_Click(object
sender, EventArgs e)
{
}
private
void button5_Click(object
sender, EventArgs e)
{
double
x = double.Parse(textBox1.Text);
//x =
double.Parse(textBox2.Text);
label3.Text =
(obj.root(x).ToString());
}
}
}
Classlibrary1:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ClassLibrary1
{
public class Class1
{
public double add(double a, double b) {
double
c;
c = a + b;
return
c;
}
public double sub(double a, double b)
{
double
c;
c = a-b;
return
c;
}
public double mul(double a, double b)
{
double
c;
c = a* b;
return
c;
}
public double div(double a, double b)
{
double
c;
c = a / b;
return
c;
}
public double root(double a)
{
double
c= Math.Sqrt(a);
return
c;
}
}
}
Build classlibrary “ctrl+shift+b”
Posted By:Tanuj Kumar
On:Shareyourconscience
Comments
Post a Comment