[Solved] Breaking a big class into smaller methods [closed]


There’s a few things I can see you’re misunderstanding based on your attempt to do this. One is the attempt to access variables in locations where they are not in scope. sender and msg are two examples. Another is that you’re not returning msg from the Send method so it can be used in the Receive method. I would suggest this article to help you understand the basics of methods in C# before proceeding.

If you’re using Visual Studio, Visual Studio Automatic Refactor will help with this, however I’d strongly encourage you to understand what the tool has done to your code once you’ve used it and not proceed until you do understand it, this is a fundamental programming concept.

Select the code you want to extract to a method, right-click, and select “Quick Actions and Refactorings…”, then “Extract Method”. The IDE will create the method and all the necessary parameters for you.

0

solved Breaking a big class into smaller methods [closed]