Hello)


Explain to me please - that's what does this error mean -

static void SearchPathBetweenCities(out string ReturnValue, CITY StartPoint, int n2 )
    {
       // ReturnValue += "\n";
        n2 += 2;
       // if (StartPoint.roadmass!=null) {}
    }

error -

Error 2 The out parameter 'ReturnValue' must be assigned to before control leaves the current method

Thanks in advance))

Edited 5 Years Ago by vedro-compota: n/a

figured out - it is better to use ref))

static void SearchPathBetweenCities(ref string ReturnValue, CITY StartPoint, int n2 )
    {
        ReturnValue += "\n";
        n2 += 2;
       // if (StartPoint.roadmass!=null) {}
    }

Edited 5 Years Ago by vedro-compota: n/a

While using out parameters, we should assign the value to the out parameter inside the function. Here i am assigning an "" to the out variable ReturnValue.

static void SearchPathBetweenCities(out string ReturnValue, CITY StartPoint, int n2 )
    {
       ReturnValue ="";
        n2 += 2;
       // if (StartPoint.roadmass!=null) {}
    }

Edited 5 Years Ago by saravind84: n/a

Comments
+++++++++++
This question has already been answered. Start a new discussion instead.