Paul
Paul

Reputation: 26650

Call class method from inside of same class instance in C#

public class MyClass {
  public static int SomeMethod(string param){
    return .....;
  }

  public int SomeMethod(string param){
    return MyClass.SomeMethod(param);
  }
}

Here when I rename class, I should rename it in all the static method calls.

In Ruby I am able to do following:

class MyClass
  def self.some_method(param)
    #.....
  end

  def some_method(param)
    self.class.some_method(param)
  end
end

How to do the same in C# ?

Upvotes: 0

Views: 1005

Answers (1)

martavoi
martavoi

Reputation: 7092

C# doesn't have similar syntax, so you should rename all the method calls.

Upvotes: 3

Related Questions