By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,994 Members | 2,073 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,994 IT Pros & Developers. It's quick & easy.

sharing class code

P: n/a
TJS
I have a class and method (class b method b) that I want to share with all
other classes, so I don't have to keep putting th same code in every class.

How is this done?
Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
TJS wrote:
I have a class and method (class b method b) that I want to share with all
other classes, so I don't have to keep putting th same code in every class.

How is this done?


[cross-posted from
microsoft.public.dotnet.framework.aspnet.buildingc ontrols...]

Assuming Class B is in the same namespace as class A, you can make B's
method static.

public class B
{
public static void DoSomething()
{
...
}
}
Then, from class A you could call DoSomething from B using:

B.DoSomething();
Also, see:

Accessing Common Code, Constants, and Functions in an ASP.NET Project
http://aspnet.4guysfromrolla.com/articles/122403-1.aspx

hth
--

Scott Mitchell
mi******@4guysfromrolla.com
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!
Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.