It is impossible to figure out how to pass a parameter to it when calling a method, except to indicate it explicitly in the first method. The idea of the task is to create in the separate Two class the one () method, which should call the already existing method of the One class so as not to duplicate the code.
class One { public static double one(Two two) { // Всё, что пришло в голову это - задать явно значения: // two.X = 1; two.Y = 1; return two.X + two.Y; } } class Two { public int X; public int Y; public double one() { return One.one(this); } } class Program { public static void Main() { Console.WriteLine(new Two().two()); } }
(new Two(){ X = 1, Y = 2 }).one()- Igornew Two() { X = 1, Y =1 };- Andrey NOPxandyvalues as parameters in the constructor. Btw public fields are bad, use at least properties. - yolosora