4

do you have any idea why the extrac method is not working on VStudio2022.

Example: be selecting following code, and if I go to EDIT->Refractor->Extract Method error appears like in the screenshoot.

No valid selection to perform extaction

var stack = new SimpleStack();
stack.Push(1.2);
stack.Push(2.8);
stack.Push(3.0);

double sum = 0.0;

while(stack.Count > 0)
{
    double item = stack.Pop();
    Console.WriteLine($"Item: {item}");
    sum += item;
}

Console.WriteLine($"Sum: {sum}");

Console.ReadLine();
  • Does it do this in other classes, or only in the new stripped-down Program.cs? – Pierre Plourde Jan 18 '22 at 16:43
  • Hi, I managed to highlight a small section of code and extracted it using edit >refactor >extract to method on a MainPage.xaml.cs (Maui), but I can't understand why this isn't on right click of highlighted code. (I'm fairly new to visual studio 2022) – gfmoore May 21 '22 at 09:02

0 Answers0