Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 845337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:26:01+00:00 2026-05-15T06:26:01+00:00

I have few global methods declared in public class in my ASP.NET web application.

  • 0

I have few global methods declared in public class in my ASP.NET web application.

I have habit of declaring all global methods in public class in following format

public static string MethodName(parameters) { }

I want to know how it would impact on performance point of view?

  1. Which one is better? Static Method or Non-Static Method?
  2. Reason why it is better?

http://bytes.com/topic/c-sharp/answers/231701-static-vs-non-static-function-performance#post947244 states:

because, static methods are using locks to be Thread-safe. The always
do internally a Monitor.Enter() and Monitor.exit() to ensure
Thread-safety.

While http://dotnetperls.com/static-method states:

static methods are normally faster to invoke on the call stack than
instance methods. There are several reasons for this in the C#
programming language. Instance methods actually use the ‘this’
instance pointer as the first parameter, so an instance method will
always have that overhead. Instance methods are also implemented with
the callvirt instruction in the intermediate language, which imposes a
slight overhead. Please note that changing your methods to static
methods is unlikely to help much on ambitious performance goals, but
it can help a tiny bit and possibly lead to further reductions.

I am little confused which one to use?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T06:26:02+00:00Added an answer on May 15, 2026 at 6:26 am

    Your first link states:

    Thats because static methods are using
    locks to be Thread-safe. The always do
    internally a Monitor.Enter() and
    Monitor.exit() to ensure Thread-safety

    That is utterly, horribly, abominably wrong.

    If you add [MethodImpl(MethodImplOptions.Synchronized)] to the method, that statement becomes partially true.

    Adding this attribute will cause the CLR to wrap static methods inside lock(typeof(YourClass)) and instance methods inside of lock(this).

    This should be avoided where possible


    Your second link is correct.
    Static methods are a little bit faster than instance methods, because they don’t have a this parameter (thus skipping a NullReferenceException check from the callvirt instruction)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.