Diff between String and string
-
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
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.
-
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
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
-
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
string
is anAlias
forSystem.String
.IL version
of bothstring
andString
isSystem.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.
-
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
-
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.
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.
-
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.
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...!!
-
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.
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!