Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends,
I have a C# application written in Visual Studio 2008 and it's solution consist of several projects. I have written a static method in a class as part of one of the projects and will want to access this static method in another project(the project containing the startup form). Please any form of help from anyone is welcome. Thank you.
Posted
Comments
Arindam Tewary 14-Jul-11 8:10am    
What stops you to access that static method in other project? What kind of help you are looking for?

1 solution

I don't see any problem here, just add a reference to the project that contains the class with the static method and call your method like this:
C#
MyClass.MyStaticMethod()
 
Share this answer
 
Comments
Tarun.K.S 14-Jul-11 8:12am    
Right. 5+
smilerP 14-Jul-11 10:14am    
Thanks Shameel for your immediate response and good solution. I had already done what you stated. The actual problem was with the scope of my static class. By default a any class added to a project is private so changing it to public did the trick. Poor me!!! I guess there is a lot to learn about Visual Studio. Thank you once again.
[no name] 14-Jul-11 11:50am    
You're welcome. Btw, the default access modifier for any Type at the namespace level is 'internal' and not 'private' as you said. Nested classes are private by default since the default access modifier at the Type level is 'private'.
Sergey Alexandrovich Kryukov 14-Jul-11 17:14pm    
Don't add more access then required. Make a separate class with public access.
--SA
Sergey Alexandrovich Kryukov 14-Jul-11 17:14pm    
A 5.
--SA

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