Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to call a function in classlibrary
Posted

You need to do the following :

1) Reference the class library in your main project.
2) create an object of the type you need.
2') in case of static classes you don't need the above.
3) call the method you need.

C#
public class classlib
{
   public void Method1()
   {
   }
   
   public static void Method2()
   {
   }
}

public class Main()
{
    classlib myClass = new classlib();
    
    myClass.Method1(); // call normal


    classlib.Method2(); // static method call
    

}
 
Share this answer
 
v2
Comments
GParkings 8-Sep-11 4:24am    
I modified your snippet to not use the reserved word 'class' as the instance name. I know it's just example code but the syntax highlighting made it a little confusing to read. hope you don't mind :)
Mehdi Gholam 8-Sep-11 4:26am    
Thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900