Can I call the Click method in the ClickAt method?

namespace ExtensionMethods { public static class MyCursorExtensions { public static void Click(this Cursor cs) { Console.WriteLine("Clicking at position"); } public static void ClickAt(this Cursor cs, Point newPosition) { Console.WriteLine("New position is {0}", newPosition); //Предполагается, что здесь я вызову Click(); } 
  • 7
    Not. I forbid even trying to do it! - αλεχολυτ
  • @alexolut, so don’t scare you like that! Suddenly really scared, but not try! :) - Rostislav Dugin
  • In general, it is better to first try to do it yourself. And in case of failure to ask questions. - V. Birkos

2 answers 2

Of course, call:

 cs.Click(); 

In the peak case:

 MyCursorExtensions.Click(cs); 

I.e:

 public static void ClickAt(this Cursor cs, Point newPosition) { Console.WriteLine("New position is {0}", newPosition); cs.Click(); // или MyCursorExtensions.Click(cs); } 

    I, of course, not special in C #. But still I dare to suggest that you can :)). When you call the method, give it a link to the Cursor .

    • True? What do you pass in the first argument when you call Click from ClickAt? :) - J.John
    • @ J.John, well, apparently, an object like Cursor :). - Rostislav Dugin
    • @Igor, and it depends how you call;) - Vadim Prokopchuk
    • Comrades, I think you need to close the question. I did not immediately guess that in this class, the Click method can be called with an object reference. "From the outside" can be called without an argument, but inside the class it is impossible) - J.John
    • one
      @ J.John, I will close it to you now! Nizya, there are answers here! :) I’ll better edit the answer. - Rostislav Dugin