8 June 2013

how to create sample dll



step 1:

---> Open microsoft vs 2010  -> new prj -> class library ->name ->dll
--->  page open then write code like this here we r creating dll for addition of two numbers..

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace dll
{
    public class Class1
    {

        public int add(int a, int b)
        {
            int c;
            c = a + b;
            return c;
        }
    }
}

// a dll file will created in folder where u save this 

// go to path where u save this class lib prj -> goto bin -> debug -> dll ** file is availble....



step 2:-

then open vs 2010 express in that -> new prj -> wpf application-> give name to the appl

page will open, and the add the refernce to this for adding ref go to sol explorer right clik refernce add refence ->dll** which we had created earlier.


 in XAML design  page just take three text boxes one for varible a another for b and the third one to store the result...

one button...after button clik jus write the code in Xaml.cs file...............


  private void button1_Click(object sender, RoutedEventArgs e)
        {
            
            dll.Class1 ob = new dll.Class1();
            int a = Convert.ToInt32(textBox1.Text);
            int b = Convert.ToInt32(textBox2.Text);
            textBox3.Text = ob.add(a, b).ToString();
     
            
        }


Lastly see the ouput 

No comments:

Post a Comment