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

Started by
2 comments, last by monchito 14 years, 9 months ago
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
Advertisement
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.
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).

[OpenTK: C# OpenGL 4.4, OpenGL ES 3.0 and OpenAL 1.1. Now with Linux/KMS support!]

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

This topic is closed to new replies.

Advertisement