SlideShare a Scribd company logo
Creating & consuming Simple Component using C# - Nithiyapriya P Page 1
Enterprise Applications using C# : Component
A component is a reusable piece of code and is in the form of “DLL”. Once a
component is designed , it can be reused from any kind of applications such as console
applications, web applications or windows applications.
A component is a collection of one or more classes that are compiled together as unit.
For example, “System.web.dll ” is a single component that provides the objects found in
many of the System.web namespace.
End user cannot interact with the DLL directly; user can interact with applications and
the applications will interact with the component or dll.
By creating component you are actually creating assembly file and it has all the
benefits that assembly has. You can edit all the assembly details by right clicking "Class
Library Project" and Selecting Properties from popup window
Creating Simple Component
1. Start visual studio 2012
2. File -> new Project-> Visual C# -> Class Library. Select the location where you wants
to save your project & and name it.
Creating & consuming Simple Component using C# - Nithiyapriya P Page 2
3. Rename the class1.cs as Calculate.cs and add coding for add, sub, mul, div methods
as given below.
Calculator.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Calculator
{
public class Calculate
{
public int Add(int a, int b)
{
return a + b;
}
public int Sub(int a, int b)
{
Creating & consuming Simple Component using C# - Nithiyapriya P Page 3
return a - b;
}
public int Mul(int a, int b)
{
return a * b;
}
public int Div(int a, int b)
{
return a / b;
}
}
}
4. Save & build Calculator
5. Now we have created calculator.dll. (you can verify it in your bindebug directory of
your class library project)
6. Goto solution explorer, Right click ; Add - > new Project-> visual c#->windows form
Application: Give a name and click ok.
7. Design your form for arithmetic calculation as given in form design.
8. Goto solution explorer. Right click on Windows form application- >Add Reference -
> browse for the calculate.dll file; check it and add to your project.
Creating & consuming Simple Component using C# - Nithiyapriya P Page 4
9. Now you can see “Calculator” under the references folder.
10. Add “using calculator” namespace on form1.cs and add the following code as given
below.
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Calculator;
namespace Minicalculator
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Calculate cal = new Calculate();
private void Form1_Load(object sender, EventArgs e)
{
}
private void Add_Click(object sender, EventArgs e)
{
int i = cal.Add(int.Parse(Txt1stNo.Text), int.Parse(Txt2ndNo.Text));
TxtResult.Text = i.ToString();
Creating & consuming Simple Component using C# - Nithiyapriya P Page 5
}
private void Sub_Click(object sender, EventArgs e)
{
int i = cal.Sub(int.Parse(Txt1stNo.Text), int.Parse(Txt2ndNo.Text));
TxtResult.Text = i.ToString();
}
private void Mul_Click(object sender, EventArgs e)
{
int i = cal.Mul (int.Parse(Txt1stNo.Text), int.Parse(Txt2ndNo.Text));
TxtResult.Text = i.ToString();
}
private void Div_Click(object sender, EventArgs e)
{
int i = cal.Div (int.Parse(Txt1stNo.Text), int.Parse(Txt2ndNo.Text));
TxtResult.Text = i.ToString();
}
private void button1_Click_1(object sender, EventArgs e)
{
this.Close();
}
}
}
11. Save the project
12. Right click on the current project and select “set as startup project” and run the
project.

More Related Content

PPT
Query optimization and processing for advanced database systems
PPTX
object oriented methodologies
PPS
Java rmi
PPTX
Packages in java
PDF
Distributed deadlock
PPTX
1.4 data independence
PPT
Conceptual dependency
PPTX
Phases of compiler
Query optimization and processing for advanced database systems
object oriented methodologies
Java rmi
Packages in java
Distributed deadlock
1.4 data independence
Conceptual dependency
Phases of compiler

What's hot (20)

PPT
15. Transactions in DBMS
PPTX
Assemblies
PPT
Java Servlets
PPTX
Dag representation of basic blocks
PPTX
Routing algorithm
PPTX
The analysis synthesis model of compilation
PPTX
Register allocation and assignment
PPTX
Transport layer
PDF
backtracking algorithms of ada
PDF
Servlet and servlet life cycle
PDF
Remote Method Invocation in JAVA
PPTX
Error Detection & Recovery
PPT
Formal Specification in Software Engineering SE9
PPTX
Issues in knowledge representation
PPTX
Cohesion and coupling
PPT
Scripting Languages
PDF
The Object Model
PPTX
And or graph
PPTX
Major issues in data mining
PPTX
TCP- Transmission Control Protocol
15. Transactions in DBMS
Assemblies
Java Servlets
Dag representation of basic blocks
Routing algorithm
The analysis synthesis model of compilation
Register allocation and assignment
Transport layer
backtracking algorithms of ada
Servlet and servlet life cycle
Remote Method Invocation in JAVA
Error Detection & Recovery
Formal Specification in Software Engineering SE9
Issues in knowledge representation
Cohesion and coupling
Scripting Languages
The Object Model
And or graph
Major issues in data mining
TCP- Transmission Control Protocol
Ad

Similar to Creating simple component (20)

PDF
Dbva dotnet programmer_guide_chapter8
PDF
Visual studio 2012
PDF
Visual basic 6.0
PPTX
Login Project with introduction .pptx
PPTX
Introduction to C# (ADO.NET) and windows Form Applications.pptx
DOCX
Lab Manual (5).docx
PPTX
hjksjdhksjhcksjhckjhskdjhcskjhckjdppt.pptx
PDF
Membangun Desktop App
PPT
Vb basics
PPTX
01. Exploring the Visual C# Toolbox (1).pptx
PDF
C# 12 Pocket Reference: Instant Help for C# 12 Programmers Joseph Albahari
DOCX
PT1420 File Access and Visual Basic .docx
PDF
Introduction To Computer Programming And Numerical Methods 1st Edition Xundon...
PDF
C# with Renas
PDF
Cp e 214_appendix_c
PPTX
Visual programming
PPTX
WP7 HUB_Introducción a Visual Studio
PPT
visual basic for the beginner
PPTX
Vb.net ide
PDF
Dbva dotnet programmer_guide_chapter8
Visual studio 2012
Visual basic 6.0
Login Project with introduction .pptx
Introduction to C# (ADO.NET) and windows Form Applications.pptx
Lab Manual (5).docx
hjksjdhksjhcksjhckjhskdjhcskjhckjdppt.pptx
Membangun Desktop App
Vb basics
01. Exploring the Visual C# Toolbox (1).pptx
C# 12 Pocket Reference: Instant Help for C# 12 Programmers Joseph Albahari
PT1420 File Access and Visual Basic .docx
Introduction To Computer Programming And Numerical Methods 1st Edition Xundon...
C# with Renas
Cp e 214_appendix_c
Visual programming
WP7 HUB_Introducción a Visual Studio
visual basic for the beginner
Vb.net ide
Ad

More from priya Nithya (19)

PPTX
Android Architecture.pptx
PDF
Html server control - ASP. NET with c#
PPTX
Modes of transfer - Computer Organization & Architecture - Nithiyapriya Pasav...
PPTX
Asynchronous data transfer
PDF
Asp.net state management
DOC
HTTP REQUEST RESPONSE OBJECT - WEB APPLICATION USING C# LAB
DOCX
HTML SERVER CONTROL - ASP.NET WITH C#
DOC
Android LAb - Creating an android app with Radio button
PPTX
ASP.NET - Life cycle of asp
DOC
Web application using c# Lab - Web Configuration file
DOCX
Creation of simple application using - step by step
PPSX
Adaptation of tcp window
PPSX
Asp.net Overview
PPSX
Key mechanism of mobile ip
PPSX
Mobile ip overview
PPSX
Features of mobile ip
PDF
Creating a Name seperator Custom Control using C#
PDF
How to Create Database component -Enterprise Application Using C# Lab
PPT
Internet (i mcom)
Android Architecture.pptx
Html server control - ASP. NET with c#
Modes of transfer - Computer Organization & Architecture - Nithiyapriya Pasav...
Asynchronous data transfer
Asp.net state management
HTTP REQUEST RESPONSE OBJECT - WEB APPLICATION USING C# LAB
HTML SERVER CONTROL - ASP.NET WITH C#
Android LAb - Creating an android app with Radio button
ASP.NET - Life cycle of asp
Web application using c# Lab - Web Configuration file
Creation of simple application using - step by step
Adaptation of tcp window
Asp.net Overview
Key mechanism of mobile ip
Mobile ip overview
Features of mobile ip
Creating a Name seperator Custom Control using C#
How to Create Database component -Enterprise Application Using C# Lab
Internet (i mcom)

Recently uploaded (20)

PDF
RMMM.pdf make it easy to upload and study
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Computing-Curriculum for Schools in Ghana
PPTX
Cell Types and Its function , kingdom of life
PPTX
Cell Structure & Organelles in detailed.
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Insiders guide to clinical Medicine.pdf
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
RMMM.pdf make it easy to upload and study
VCE English Exam - Section C Student Revision Booklet
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Computing-Curriculum for Schools in Ghana
Cell Types and Its function , kingdom of life
Cell Structure & Organelles in detailed.
Pharma ospi slides which help in ospi learning
Pharmacology of Heart Failure /Pharmacotherapy of CHF
TR - Agricultural Crops Production NC III.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Insiders guide to clinical Medicine.pdf
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
STATICS OF THE RIGID BODIES Hibbelers.pdf
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
O7-L3 Supply Chain Operations - ICLT Program
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
FourierSeries-QuestionsWithAnswers(Part-A).pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
human mycosis Human fungal infections are called human mycosis..pptx

Creating simple component

  • 1. Creating & consuming Simple Component using C# - Nithiyapriya P Page 1 Enterprise Applications using C# : Component A component is a reusable piece of code and is in the form of “DLL”. Once a component is designed , it can be reused from any kind of applications such as console applications, web applications or windows applications. A component is a collection of one or more classes that are compiled together as unit. For example, “System.web.dll ” is a single component that provides the objects found in many of the System.web namespace. End user cannot interact with the DLL directly; user can interact with applications and the applications will interact with the component or dll. By creating component you are actually creating assembly file and it has all the benefits that assembly has. You can edit all the assembly details by right clicking "Class Library Project" and Selecting Properties from popup window Creating Simple Component 1. Start visual studio 2012 2. File -> new Project-> Visual C# -> Class Library. Select the location where you wants to save your project & and name it.
  • 2. Creating & consuming Simple Component using C# - Nithiyapriya P Page 2 3. Rename the class1.cs as Calculate.cs and add coding for add, sub, mul, div methods as given below. Calculator.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Calculator { public class Calculate { public int Add(int a, int b) { return a + b; } public int Sub(int a, int b) {
  • 3. Creating & consuming Simple Component using C# - Nithiyapriya P Page 3 return a - b; } public int Mul(int a, int b) { return a * b; } public int Div(int a, int b) { return a / b; } } } 4. Save & build Calculator 5. Now we have created calculator.dll. (you can verify it in your bindebug directory of your class library project) 6. Goto solution explorer, Right click ; Add - > new Project-> visual c#->windows form Application: Give a name and click ok. 7. Design your form for arithmetic calculation as given in form design. 8. Goto solution explorer. Right click on Windows form application- >Add Reference - > browse for the calculate.dll file; check it and add to your project.
  • 4. Creating & consuming Simple Component using C# - Nithiyapriya P Page 4 9. Now you can see “Calculator” under the references folder. 10. Add “using calculator” namespace on form1.cs and add the following code as given below. Form1.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using Calculator; namespace Minicalculator { public partial class Form1 : Form { public Form1() { InitializeComponent(); } Calculate cal = new Calculate(); private void Form1_Load(object sender, EventArgs e) { } private void Add_Click(object sender, EventArgs e) { int i = cal.Add(int.Parse(Txt1stNo.Text), int.Parse(Txt2ndNo.Text)); TxtResult.Text = i.ToString();
  • 5. Creating & consuming Simple Component using C# - Nithiyapriya P Page 5 } private void Sub_Click(object sender, EventArgs e) { int i = cal.Sub(int.Parse(Txt1stNo.Text), int.Parse(Txt2ndNo.Text)); TxtResult.Text = i.ToString(); } private void Mul_Click(object sender, EventArgs e) { int i = cal.Mul (int.Parse(Txt1stNo.Text), int.Parse(Txt2ndNo.Text)); TxtResult.Text = i.ToString(); } private void Div_Click(object sender, EventArgs e) { int i = cal.Div (int.Parse(Txt1stNo.Text), int.Parse(Txt2ndNo.Text)); TxtResult.Text = i.ToString(); } private void button1_Click_1(object sender, EventArgs e) { this.Close(); } } } 11. Save the project 12. Right click on the current project and select “set as startup project” and run the project.