two classes

S

Scott Mitchell [MVP]

TJS said:
how can I call class b method b, from class a method a ?

Class A has to be able to reference Class B somehow. Does class A
contain an instance of Class B as a member variable? Is B somehow
global to A such that A can reference B?

A better way to get an answer to your question might be to give a more
specific breakdown of what you're trying to do...

--

Scott Mitchell
(e-mail address removed)
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!
 
T

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?
 
S

Scott Mitchell [MVP]

TJS said:
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?

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();


hth

--

Scott Mitchell
(e-mail address removed)
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!
 
V

Victor Garcia Aprea [MVP]

Hi TJS,

Your question is not about ASP.NET nor about bulding controls for ASP.NET
(the topic for the newsgroup you posted to). I guess you will get better
luck by posting to a language-specific newsgroup.

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx

To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top