Sign in to follow this  

[.net] accesing functions(code) in other files

This topic is 3093 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, i'm new.... and using VC# 2008 express edition In visual basic normally i put the code in a module that i can use in other projects or different forms in the same project. Typically is generic code and math algorithms. I don't want the generic code to belong to the form, only their button clicks, etc. How can i do the same in c# Thanks in advance

Share this post


Link to post
Share on other sites
You need to create new project. Select its type as Class Library. You can add it to same solution as your executable project. Then add reference to this newly created class library project in your executable project.

Share this post


Link to post
Share on other sites
VB.Net modules are glorified static classes. This is the equivalent in C#:


static class MathUtilities
{
public static void Add(ref Vector3 left, ref Vector3 right, out Vector3 result)
{
...
}
}


However, think long and hard whether these helper functions should actually be in a static class (in the above example, the Add method should have been a member of the Vector3 class).

Share this post


Link to post
Share on other sites
Thanks for the ideas.
Actually is for the (double[] array) data of a grid control that i use.
I need to use the data array to perform different tasks in many forms.
Now i can call the functions from the forms and do the operations.
Note: ... and yes i have my vector3, vector2, quaternions...pretty concealed

Share this post


Link to post
Share on other sites

This topic is 3093 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this