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 6209881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:03:48+00:00 2026-05-24T06:03:48+00:00

I have two questions, stemming from observed behavior of C# static methods (which I

  • 0

I have two questions, stemming from observed behavior of C# static methods (which I may be misinterpretting):

First:
Would a recursive static method be tail call optimized in a sense by the way the static method is implemented under the covers?

Second:
Would it be equivalent to functional programming to write an entire application with static methods and no variables beyond local scope? I am wondering because I still haven’t wrapped my head around this “no side effects” term I keep hearing about functional programming..

Edit:
Let me mention, I do use and understand why and when to use static methods in the normal C# OO methodology, and I do understand tail call optimization will not be explicitly done to a recursive static method. That said, I understand tail call optimization to be an attempt at stopping the creation of a new stack frame with each pass, and I had at a couple points observed what appeared to be a static method executing within the frame of it’s calling method, though I may have misinterpreted my observation.

  • 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-24T06:03:49+00:00Added an answer on May 24, 2026 at 6:03 am

    Would a recursive static method be tail call optimized in a sense by the way the static method is implemented under the covers?

    Static methods have nothing to do with tail recursion optimization. All the rules equally apply to instance and static methods, but personally I would never rely on JIT optimizing away my tail calls. Moreover, C# compiler doesn’t emit tail call instruction but sometimes it is performed anyway. In short, you never know.

    F# compiler supports tail recursion optimization and, when possible, compiles recursion to loops.
    See more details on C# vs F# behavior in this question.

    Would it be equivalent to functional programming to write an entire application with static methods and no variables beyond local scope?

    It’s both no and yes.

    Technically, nothing prevents you from calling Console.WriteLine from a static method (which is a static method itself!) which obviously has side-effects. Nothing also prevents you from writing a class (with instance methods) that does not change any state (i.e. instance methods don’t access instance fields). However from the design point of view, such methods don’t really make sense as instance methods, right?

    If you Add an item to .NET Framework List<T> (which has side effects), you will modify its state.
    If you append an item to an F# list, you will get another list, and the original will not be modified.

    Note that append indeed is a static method on List module. Writing “transformation” methods in separate modules encourages side-effect free design, as no internal storage is available by definition, even if the language allows it (F# does, LISP doesn’t). However nothing really prevents you from writing a side-effect free non-static method.

    Finally, if you want to grok functional language concepts, use one! It’s so much more natural to write F# modules that operate immutable F# data structures than imitate the same in C# with or without static methods.

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

Sidebar

Related Questions

I have two questions: 1) How can I make an array which points to
I have two questions: From personal experience, what free blog engine is the best
I have two questions about Google's dense_hash_map , which can be used instead of
I have two questions regarding python libraries: I would like to know if there
I have two questions. First one is simple: Is there any way to control
I have two questions. My first one is, that how can i put something
I have two questions. In C++, a static member function has direct access to
I have two questions.They both are concerning a void in C++,which I am trying
I have two questions (does that violate etiquette?) surrounding Twitter authentication. The first question
I have two questions. The first is about updating the UI, the second is

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.