Производительность статических методов по сравнению с методами экземпляра

Мой вопрос касается характеристик производительности статических методов по сравнению с методами экземпляров и их масштабируемости. Предположим для этого сценария, что все определения классов находятся в одной сборке и что требуется несколько типов дискретных указателей.

Рассматривать:

public sealed class InstanceClass
{
      public int DoOperation1(string input)
      {
          // Some operation.
      }

      public int DoOperation2(string input)
      {
          // Some operation.
      }

      // … more instance methods.
}

public static class StaticClass
{
      public static int DoOperation1(string input)
      {
          // Some operation.
      }

      public static int DoOperation2(string input)
      {
          // Some operation.
      }

      // … more static methods.
}

Вышеуказанные классы представляют шаблон стиля помощника.

В классе экземпляра для разрешения метода экземпляра требуется время, в отличие от StaticClass.

Мои вопросы:

When keeping state is not a concern (no fields or properties are required), is it always better to use a static class?

Where there is a considerable number of these static class definitions (say 100 for example, with a number of static methods each) will this affect execution performance or memory consumption negatively as compared with the same number of instance class definitions?

When another method within the same instance class is called, does the instance resolution still occur? For example using the [this] keyword like this.DoOperation2("abc") from within DoOperation1 of the same instance.

Ответы на вопрос(3)

Ваш ответ на вопрос