Assemblies and using them in console app

 

1) create a class library project (i.e our assembly)

2) add this code to the class automatically created to the .cs file (i.e Class1.cs)

public int addition(int fn,int sn)

        {

            return fn + sn;

        }

        public int subtraction(int fn, int sn)

        {

            return fn - sn;

        }

3)add a console application to the solution also add reference of class library to the project.

4)add this code to the main method of the .cs file (i.e Program.cs)

using assembly (cuz 'assembly' is my class library name)

Class1 obj = new Class1();

            int v1 = obj.addition(10,20);

            

            Console.WriteLine(v1);

            Console.ReadLine();

          

            Console.WriteLine("assembly created");

            Console.ReadLine();

5)set the console app as startup project

Comments

Popular posts from this blog

WCF service