-
April 2nd, 2011, 06:34 PM
#1
Get size of a StringBuilder
I can't seem to find this info anywhere, what is the call to get the number of bytes? I know I can do ToString() and then get the number but that is quite inefficient.
-
April 2nd, 2011, 06:38 PM
#2
Re: Get size of a StringBuilder
Ok I found it, it's .Length. I was trying with trial and error but I always have trouble figuring out the spelling to that word so I must have gotten it wrong. I wish they would all use Size. So much easier. lol
-
April 2nd, 2011, 07:03 PM
#3
Re: Get size of a StringBuilder
Yep, sometimes, Length, sometimes Size, sometimes Count and sometimes Count()...
Rob
-
Ohhhhh.... Old McDonald was dyslexic, E O I O EEEEEEEEEE.......
-
April 4th, 2011, 02:20 AM
#4
Re: Get size of a StringBuilder
Maybe because count of elements in the collection cannot be neccessary same as lenght of the space allocate ;-) And Count() is the price of extension method. But despite I see the reasons, I think it could be unified.
- Make it run.
- Make it right.
- Make it fast.
Don't hesitate to rate my post.
-
April 4th, 2011, 01:28 PM
#5
Re: Get size of a StringBuilder
itn count = Encoding.ASCII.GetByteCount(string);
-
April 4th, 2011, 05:47 PM
#6
Re: Get size of a StringBuilder
Yes, I think the problem is actually the English language, not the C# language.
Rob
-
Ohhhhh.... Old McDonald was dyslexic, E O I O EEEEEEEEEE.......
-
April 5th, 2011, 06:12 PM
#7
Re: Get size of a StringBuilder
Originally Posted by Red Squirrel
Ok I found it, it's .Length. I was trying with trial and error but I always have trouble figuring out the spelling to that word so I must have gotten it wrong. I wish they would all use Size. So much easier. lol
Have you heard of Msdn?
StringBuilder class
In Msdn, all the constructors, properties, methods, events and so on are listed for each class.
If you are using a new class, check it out in Msdn and notice what's available - even if you don't need it this time, you might remember enough for next time.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|