I am learning how to program and I am trying to reuse part of my code. I have duplicated chunk of code all over OnBarUpdate(). Instead of repeating this code I would like to create an object (or whatever proper name applies) and can call it when needed.
Question 1: Creating a method is what I need? eg:
static void MyMethod() { Console.WriteLine("I just got executed!"); }
Question 3: and then call it from OnbarUpdate() like this?
MyMethod();
Question 4: When trying to compile I am receiving error saying "An object reference is required for the on-static field, method or property...."
Thanks in advance for your help.
Comment