Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to write 'hello world' in classlibrary.cs ,simple program so as to make myself understand how it is done and further make dll and use in project.i want a basic program.
Posted
Comments
Prerak Patel 6-Sep-11 2:16am    
Stop reposting the same question.

You have already asked it over here, want basic code for class library function and how to implement namespace.[^]
So, you could have wait for few time to some one respond.
If you check out the link I have provided, has step by step explanation.

Create a Class Library Project > Write a Method

Public Class MyClassLibrary
    {
      public static string MyHelloMethod()
         {
            return "Hello World";
         }

    }


Build the dll. Add the project as reference to the calling project.

Add the namespace if its different projects.

Then,
Console.WriteLine(MyClassLibrary.MyHelloMethod())
;

This will print, "Hello World" in your output screen.

Note, I used the static method, to directly call with out creating object. Hope you know that.
 
Share this answer
 
Comments
raj_sagoo 6-Sep-11 2:34am    
thanks alot ,but what will be the namespace to be add in different project.
Abhijit Jana 6-Sep-11 2:39am    
The namespace of your class library. you need to put it as Using . Check out my answer to your last post. I have given couple of useful links for you !
raj_sagoo 6-Sep-11 3:14am    
in my default.aspx page i have taken a label with id lblMessage but its not coming in intellisense,i have add reference and added a dll in bin folder of my project(websiteproject).what could be the reason for that.
raj_sagoo 6-Sep-11 3:27am    
i have created am object also
In order to do that you have to write the dll and the calling assembly (exe).

Try first programming the hello world for example to a console application. When that's fine, add a class library project to your solution, reference it in your console application solution, create a class in the dll where you place the hello world code in a method.

After that istantiate the class in the console application and call the method. While running, use the debugger to see what's happening at each step.
 
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