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

  • SEARCH
  • Home
  • 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 4590972
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:19:40+00:00 2026-05-21T22:19:40+00:00

I installed resharper and it suggested to me that I should modify some local

  • 0

I installed resharper and it suggested to me that I should modify some local variables to a const. I never heard of this, so I starting googling. MSDN sure enough has a bit of code of having local consts, but no explanation why. On stackoverflow I came across questions but had more to do with whether having a local const is faster than not having them.

So, I’m scratching my head here. Why is it possible to have a local const? Does it have to do with semantics? Is there some benefit? Maybe both?

  • 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-21T22:19:41+00:00Added an answer on May 21, 2026 at 10:19 pm

    Const have a main benefit: it’s value is unchangeable and this enforce code stability and solidness.

    Let’s say you’ve to define some date format during some method execution and it’s valid for this one only. Why don’t you’d be using a constant?

    public void SomeMethod()
    {
        const string dateFormat = "MM/dd/yyyy";
    
        ... // Lot of operations
    
    
        return Date.Now.ToString(dateFormat);
    }
    

    You avoid human errors if you use constants if it’s possible to use them.

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

Sidebar

Related Questions

This happen after I installed the ReSharper. It's a problem that if I fix
I installed Resharper in VS2008 and it seems to have taken over some of
This is regarding Visual Studio pro 2008 sp1, with resharper and testdriven installed. I've
This is driving me crazy. Ever since I installed ReSharper 4, F12 no longer
I've just installed Resharper, and I really don't know how to use it correctly.
Recenty I installed ReSharper 4.5. It has a cool new feature of checking naming
I installed the ReSharper evaluation version and uninstalled it. Afterwards Visual Studio's Intellisense stopped
I have resharper installed and I use the todo list functionality pretty often. My
I have ReSharper installed with Visual Studio on a machine. I want to now
I've never understood this, and frankly, it pisses me off to see it in

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.