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))

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) {}
    }
Member Avatar for saravind84

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) {}
    }
commented: +++++++++++ +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.