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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T04:12:58+00:00 2026-05-11T04:12:58+00:00

Help me settle an argument here. Is this: SqlCommand cmd = new SqlCommand( sql

  • 0

Help me settle an argument here.

Is this:

SqlCommand cmd = new SqlCommand( 'sql cmd', conn); 

treated exactly the same as this:

const string s = 'sql cmd'; SqlCommand cmd = new SqlCommand( s, conn); 

Ie. does it make a difference if I state specifically that the string s is a const.

And, if it is not treated in the same way, why not?

  • 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. 2026-05-11T04:12:58+00:00Added an answer on May 11, 2026 at 4:12 am

    In the latter snippet, it’s not that the string is const – it’s that the variable is const. This is not quite the same as const in C++. (Strings are always immutable in .NET.)

    And yes, the two snippets do the same thing. The only difference is that in the first form you’ll have a metadata entry for s as well, and if the variable is declared at the type level (instead of being a local variable) then other methods could use it too. Of course, due to string interning if you use ‘sql cmd’ elsewhere you’ll still only have a single string object in memory… but if you look at the type with reflection you’ll find the const as a field in the metadata with the second snippet if it’s declared as a constant field, and if it’s just a local variable it’ll be in the PDB file if you build one.

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

Sidebar

Ask A Question

Stats

  • Questions 521k
  • Answers 521k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Please refer How to remove close button on the jQuery… May 16, 2026 at 9:00 pm
  • Editorial Team
    Editorial Team added an answer As others have mentioned, you can use the :not() selector.… May 16, 2026 at 9:00 pm
  • Editorial Team
    Editorial Team added an answer This solution: htmlPane.setContentsURL("http://www.chellasoftapp.com/ATBrowser/images/disclaimer.html"); has quite big disadventage. It doesn't work… May 16, 2026 at 9:00 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Help settle the debate that's going on in the comments at this question about
help me please with this simple E-sql query: var qStr = SELECT SqlServer.Month(o.DatePaid) as
Help me settle a dispute with a coworker: Does setting a variable or collection
Please help us settle the controversy of Nearly everything is an object ( an
Here's a bit of a different question for you computer history buffs. Help me
Need help understanding what I am doing with the syntax here, please help! I
Please help me with this MySQL query. I've been on it for long enough.
Any help with this problem would be fantastic. I appreciate all contributions! Let us
My co-workers and I are having an argument over the value and usage of
I have a regex issue that I need help with. Its trying to validate

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.