Congratulations to all the winners of April 2013, they have won INR 3400 cash and INR 20147 worth prizes !
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 8580 |  Welcome, Guest!   Register  Login
 Home > Interview Questions > C# Interview Questions > How to write a method in a class and bui ...

How to write a method in a class and build as .dll

Interview question and answer by: Poster | Posted on: 6/16/2009 | Category: C# Interview questions | Views: 2129 |


Answer:

To generate a .dll you can following below steps

1. Right click your solution and select New Project.
2. Select Visual C# as Project type and Class Library as Templates (give proper name and location path) and click OK.
3. Write some code in the class like below, you can add as many class you want.
using System;

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

namespace ClassLibrary1
{
public class Class1
{
public string GetMyName(string myName)
{
return myName;
}
}

4. Right click the Class Library project and select build.
5. Your .dll should be ready in the bin folder of the project location (either in the debug or release folder) depends on which mode your project is.
6. To refer this .dll, you can right click your project and select Add References.
7. Select browse tab from the dialogue box and choose the .dll you have just generated.
8. Now to use the method of the class library in any code behind page or another class library, you can use the namespace you had used in the class library (in above case ClassLibrary1) like "using ClassLibrary1;"
9. Instantiate the class and use its method like below
Class1 c = new Class();

string myName = c.GetMyName("Poster");


Thanks :)

Asked In: Many Interviews | Alert Moderator 
Found interesting? Add this to:


 Responses

Posted by: Vuyiswamb | Posted on: 17 Jun 2009 01:14:18 AM | Alert Moderator 

That is Good

Posted by: Mcadeepuraj | Posted on: 12 Aug 2011 12:10:18 AM | Points: 10 | Alert Moderator 

Nice

>> Write Response - Respond to this post and get points

Even more ... | Submit Interview Questions and win prizes!

More Interview Questions from Poster

Even more ... | Submit Interview Questions and win prizes!


About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/18/2013 2:23:32 PM