VR Indian Wanderers Youtube Facebook RSS Feed
Learn with Vikas Suhag
Design an application that uses the user defined Dynamic Link Library in Window Application
Nov 16, 2021   Vikas Suhag

C#.NET program using DLL

AIM :  Design an application that uses the user defined Dynamic Link Library in Window Application.

Source Code :

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;

using ClassLibrary1;

 

namespace WindowsFormsApplication1

{

    public partial class Form1 : Form

    {

        int a, b, c;

        Class1 o = new Class1();

        public Form1()

        {

            InitializeComponent();

        }

 

// Addition

        private void button1_Click(object sender, EventArgs e)

        {

 

            a = Int32.Parse(textBox1.Text);

            b = Int32.Parse(textBox2.Text);

            c = o.add(a,b);

            MessageBox.Show("Addition is "+c.ToString());  

        }

// Subtraction

        private void button2_Click(object sender, EventArgs e)

        {

            a = Int32.Parse(textBox3.Text);

            b = Int32.Parse(textBox4.Text);

            c = o.sub(a,b);

            MessageBox.Show("Subtraction is " + c.ToString());

        }

 

 

//  Swaping

 

        private void button3_Click(object sender, EventArgs e)

        {

            a = Int32.Parse(textBox5.Text);

            b = Int32.Parse(textBox6.Text);

            o.swap(ref a,ref b);

            textBox5.Text = a.ToString();

            textBox6.Text = b.ToString();

        }

// Factorial

        private void button4_Click(object sender, EventArgs e)

        {

            b = Int32.Parse(textBox7.Text);

            c=o.fact(b);

            MessageBox.Show("Factorial is " + c.ToString());

        }

     

    }

}

 

// Class Liberary

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

 

namespace ClassLibrary1

{

    public class Class1

    {

        public int add(int a, int b)

        {

            return (a + b);

        }

        public int sub(int a, int b)

        {

            return (a - b);

        }

        public void swap(ref int a, ref int b)

        {

            int c;

            c = a;

            a = b;

            b = c;

        }

        public int fact(int b)

        {

            int a = 1;

            for (int i = b; i > 0; i--)

            {

                a = a * i;

            }

            return a;

        }

    }

}

Output


Leave a Comment

* Email will not be published.
All comments are only visible after approval.
Most Viewed articles
Travel Blog - VR Indian Wanderers
VR Indian Wanderers
Govt. Jobs Portal
Govt. Jobs Portal
Free Chart Maker
Make free animated Charts from .CSV
Search
Youtube Channel
Podcast
Subscribe to Email Updates
Connect With Us
VR Indian Wanderers Youtube Facebook RSS Feed
© 2024 Learn with Vikas Suhag. All Rights Reserved.