On Monday, I was corrected in my assertion that creating multiple empty strings would create multiple objects. Turns out the compiler automatically puts all of the strings that are exactly the same in a “string pool” so that there is only ever one empty string in the entire application you’ve created.
Duh! I should have known this, or at least I should have expected that this was so since it has been true with every other compiled language I’ve worked with.
But what I didn’t know and couldn’t expect is that we can make use of this string pool programmatically as well.
Continue reading “.Net String Pool – Not Just For The Compiler”
I recently read an article that argued that “” is “Better than String.Empty”
The argument is that since string.Empty doesn’t work in all situations, we should not use it at all. He further argues that since the compiler can’t optimize code using string.Empty, the performance gains we might lose due to our lack of this optimization further supports the argument that we should not use it at all.
But at what price?
Continue reading “C# “” better than string.Empty?”
I just read a post by Casademora on “public abstract string Blog()”
Just say No! to C# Regions « public abstract string Blog()
I still say Regions are not useful… but…
arguing that not only should we NOT use code regions, but if we do, we are hiding “bad code.” He uses words like “retarded,” “lame excuse for a preprocessor tag,” etc.
You’d think maybe this guy (gal?) just had a bad day when he wrote this, but no, he goes on to further defend his position in a later post.
And what I don’t understand at all is how his original post ended up on DotNetKicks today. It’s an old post that was written last year but was just kicked up to the front page? I figure someone MUST agree with him or it wouldn’t be there.
So, are Regions really as evil as Casademora argues that they are?
Continue reading “Just say “No!” to C# Regions? Really?!”
So here’s the question:
I’m using String.Split() and need to pass in a Char or a Char array as the parameter. If I pass in a string String.Split(“/”) I get an error “Option Strict On disallows implicit conversions from ‘String’ to ‘Char’.”
Obviously, the easiest way to fix this would be to turn off Option Strict, but I would prefer to keep it on. So how do I pass in the Char instead of a String in this situation?”
Continue reading “VB.NET – Char from String with Option Strict”