cjard
Well-known member
- Joined
- Apr 25, 2006
- Messages
- 7,081
- Programming Experience
- 10+
StringBuilder comment noted, but dont worry.. VB uses it anyway..
If you compile my example, then decompile it with a simplistic decompiler you'll get:
String s = New StringBuilder("hello").Append(myVariable).Append("world").ToString()
So dont worry.. StringBuilder is used every time you concatenate a string - you just dont see it because it goes into the IL. Your point of explicitly using one is valid though, as you can preset known capacities and re-use it to save creation of stringBuilder objects all the time.
I originally posted because I wanted to comment out a argument in a method:
its just it was easier to write a string example than paste the method in, which is significantly more messy. Glad the debate arose though, cause some good points always come out of them - in a way, i never mind threads that go OT once the original question is answered, because more knowledge is spread as a result..
If you compile my example, then decompile it with a simplistic decompiler you'll get:
String s = New StringBuilder("hello").Append(myVariable).Append("world").ToString()
So dont worry.. StringBuilder is used every time you concatenate a string - you just dont see it because it goes into the IL. Your point of explicitly using one is valid though, as you can preset known capacities and re-use it to save creation of stringBuilder objects all the time.
I originally posted because I wanted to comment out a argument in a method:
VB.NET:
mySub( p1, _
p2, _
Nothing, _ 'p3, _
p4 _
)
its just it was easier to write a string example than paste the method in, which is significantly more messy. Glad the debate arose though, cause some good points always come out of them - in a way, i never mind threads that go OT once the original question is answered, because more knowledge is spread as a result..