Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Diff between String and string

Diff between String and string

Scheduled Pinned Locked Moved ASP.NET
performance
8 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hi all When i am declaring String type variable. What shaould i use String OR string Is this effect on performance. Thanks and regards, Amit Patel

    D M A D 4 Replies Last reply
    0
    • L Lost User

      Hi all When i am declaring String type variable. What shaould i use String OR string Is this effect on performance. Thanks and regards, Amit Patel

      D Offline
      D Offline
      Dinesh Mani
      wrote on last edited by
      #2

      Even I'm not sure! When I once asked this to one of the MCTs that I know, he said its better to use "String" for declaring string type variables, but he wasn't able to give me any reasons either! But, I rarely use String/string type variables. I use StringBuilder for all string manipulations.

      A D 2 Replies Last reply
      0
      • L Lost User

        Hi all When i am declaring String type variable. What shaould i use String OR string Is this effect on performance. Thanks and regards, Amit Patel

        M Offline
        M Offline
        m khansari
        wrote on last edited by
        #3

        Hi String is a .net data type string is a C# data type I think that there is no difference. My Reason: right click on the string and select "Go To Definition" from string's context menu it refers to String definition

        Mohammad Khansari

        1 Reply Last reply
        0
        • L Lost User

          Hi all When i am declaring String type variable. What shaould i use String OR string Is this effect on performance. Thanks and regards, Amit Patel

          A Offline
          A Offline
          Abhijit Jana
          wrote on last edited by
          #4

          string is an Alias for System.String. IL version of both string and String is System.String. So there is no difference between them. :)

          Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

          1 Reply Last reply
          0
          • L Lost User

            Hi all When i am declaring String type variable. What shaould i use String OR string Is this effect on performance. Thanks and regards, Amit Patel

            D Offline
            D Offline
            dan sh
            wrote on last edited by
            #5

            No differece. Both are same.

            50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!

            1 Reply Last reply
            0
            • D Dinesh Mani

              Even I'm not sure! When I once asked this to one of the MCTs that I know, he said its better to use "String" for declaring string type variables, but he wasn't able to give me any reasons either! But, I rarely use String/string type variables. I use StringBuilder for all string manipulations.

              A Offline
              A Offline
              Abhijit Jana
              wrote on last edited by
              #6

              Dinesh Mani wrote:

              But, I rarely use String/string type variables. I use StringBuilder for all string manipulations.

              StringBuilder is usefull when you are doing a large string ( inside loops ) operation. For Small operation its always preferable use string not stringBuilder.

              Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

              D 1 Reply Last reply
              0
              • D Dinesh Mani

                Even I'm not sure! When I once asked this to one of the MCTs that I know, he said its better to use "String" for declaring string type variables, but he wasn't able to give me any reasons either! But, I rarely use String/string type variables. I use StringBuilder for all string manipulations.

                D Offline
                D Offline
                dan sh
                wrote on last edited by
                #7

                Dinesh Mani wrote:

                use "String" for declaring string type variables

                Apart from having that sort of coding guidelines, I see no reason of doing that.

                50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!

                1 Reply Last reply
                0
                • A Abhijit Jana

                  Dinesh Mani wrote:

                  But, I rarely use String/string type variables. I use StringBuilder for all string manipulations.

                  StringBuilder is usefull when you are doing a large string ( inside loops ) operation. For Small operation its always preferable use string not stringBuilder.

                  Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

                  D Offline
                  D Offline
                  Dinesh Mani
                  wrote on last edited by
                  #8

                  I just use StringBuilder when I know that a specified string is going to be modified more than 2 times after the original assignment, otherwise I use general String/string. I guess its just general preference!

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups