Okay so a new problem presents itself to me. I have an intense source code that is currently about 5,000 lines long and is quite frustrating to manage. I want to learn how to use multiple source files, like with c++ you would use include.

// It says it's C# syntax but this is C++ sorry guys. :(
#include <sourceOne.cpp>
#include <sourceTwo.cpp>
#include "headerOne.h"

That kind of thing, I'm creating a windows forms application and this source is getting quite massive. So can anyone explain to me how to do multiple source files? Or even creating dll files for the application to use would help me out. :)

Also, I haven't really had much experience creating pointers but would love to learn how if anyone is willing to give a brief explanation on it. I know what they are so at least that's a start. :)


Do you want help with C# or C++?

C# doesn't have the equivalent of header files. The closest thing is the using statements at the top of the file, but those are just shortcuts to the classes contained in those namespaces. For example, adding using System; allows you to use the String class without having to say System.String .

If you want to split your classes into multiple files you just do it and include them in the project. The compiler will find them. If you want to split a class into multiple files you declare it a partial class (look at the declaration of a form you create for an example).

Creating a DLL is just a different type of project and once created you add it to your references in the project tab.

Actually not what I meant, thought this was explanatory, I already knew all of that information. I would like some basic examples. Like function calling using a pointer, multiple .cs file function calling, and creating pointers for functions in the same .cs file.

So can anyone explain to me how to do multiple source files?

May not be what you meant, but it was what you asked.

You don't use pointers in C#, except in rare situations that you probably won't run into. So, instead of function pointers, we use Delegates:

delegate void MyDelegate(int i);

class Program {
    static void Main() {
        MyDelegate function = DelegateFunction;
        function = OtherDelegateFunction;

    static void DelegateFunction(int i) {

    static void OtherDelegateFunction(int i) {

The first line declares a new delegate type that returns nothing and takes an int as a parameter. Line 5 declares a reference to this delegate type, and assigns a value to it. We then call it in line 6, assign a new reference in 7 and again call it in 8.

Delegates are used frequently in GUI programming when you assign a method to an event. Events are a special type of delegate.

int x = 100; // We can assign this to a simple pointer.

int *xPointer = & x;
Console.WriteLine((int)xPointer); // Displays the memory address.
Console.WriteLine(*xPointer); // Displays the value at the memory address.

I know about delegates but don't prefer to use them. I come from MIPS Assembly where pointers and hooks for function calling are the best. So I just wanted to figure out how pointers work. Assigning them to the values I have declared near the top of my source.