I'm using GitLab and C# with Visual Studio.

I have a C# class (ClassOne) in my directory. Then I created another C# class file (ClassTwo) in the local directory and pushed both.

But the problem is, in my second class file, I want to use some methods of the first class but it doesn't recognize the first class. Both of the classes are in the same folder (Git Repo) though!

First class:

using System;
using System.Collections.Generic;

namespace sorooshTest
{
    public class ClassOne
    {
        public ClassOne()
        {
        }

        static public List<double> FirstMethod(List<double> inputPoints, double taw)
        {
            //some code
        }

        static public List<double> SecondMethod(List<double> inputPoints)
        {
            //some code
        }
    }
}

And the second class:

using System;

public class ClassTwo
{
    public BoolTest()
    {
    }

    static public bool B2C()
    {
        // nothing here works, e.g. var a = ClassOne.FirstMethod(b,c)
    }

}

I cannot also inherit from the ClassOne.

1 Answers

2
Michael Randall On Best Solutions

Include the class into the project, If the project file has no idea about the new C# file, then you cant do anything with it in the code.

Right click project ->  Add -> Add Existing Item -> choose your file