0

I'm sure this is something simple. I'm not very familiar with C# (I'm actually porting this over from C++).

I am calling the method CalculateLines which is in the class CalculateFrontages after an 'OK' click (snippet):

 private void Button_Click(object sender, RoutedEventArgs e)
    {
        //     MessageBox.Show("User clicked OK");

        string value = MSTGapThresholdInMeters.Text;
        MSTGapValue = Int32.Parse(value);

        MainWindowViewModel.RedTLS =  CalculateFrontages.CalculateLines(MainWindowViewModel.RedArmy, Map.MetersPerPixel, MSTGapValue);
        MainWindowViewModel.BlueTLS = CalculateFrontages.CalculateLines(MainWindowViewModel.BlueArmy, Map.MetersPerPixel, MSTGapValue);

        this.DialogResult = true;
    }

And this is the method, CalculateLines, which is in another class, CalculateFrontages, that I want to call (snippet):

namespace TacticalAILib
{
public class CalculateFrontages
{

    static int[] U;

    private static TacLineStruct CalculateLines(List<MATEUnit> Army, double MetersPerPixel, int MSTGapValue)
    {

        int TempFrom, TempTo;
        float TempWeight;
        int NumEdges = 0;
        double Threshold = MetersPerPixel * MSTGapValue;
        U = new int[Army.Count];

And it's throwing this compiler error:

Error CS0426 The type name 'CalculateLines' does not exist in the type 'CalculateFrontages'

I assume it's a scope error, or a declaration error. I just don't know enough about this.

halfer
  • 19,824
  • 17
  • 99
  • 186
zetar
  • 1,225
  • 2
  • 20
  • 45
  • 3
    Well, it's `private`, isn't it. – GSerg Apr 25 '19 at 16:14
  • 1
    `private static TacLineStruct CalculateLines...` If it is private it cant be referenced outside the class. That error message doesnt seem to match that code though. – Ňɏssa Pøngjǣrdenlarp Apr 25 '19 at 16:17
  • *"Error CS0122 'CalculateFrontages.CalculateLines()' is inaccessible due to its protection level"* rather, no ? – Cid Apr 25 '19 at 16:22
  • Or there is another class named `CalculateFrontages` in another namespace than `TacticalAILib` – Cid Apr 25 '19 at 16:22
  • (There is much value in assuming the best of your readers when asking a question. If you tell people you assume they will downvote unreasonably, then downvotes may be the result of that remark. Please try to omit unnecessary and conversation material from questions, and stick to the problem itself. Thanks!) – halfer May 04 '19 at 10:30

1 Answers1

2

The method's accessibility level is private, that means other any request can not reach that function exept the owner class. If you update it to public, you can reach it from anywhere..

Cotur
  • 450
  • 2
  • 10