Last weekend was a holiday weekend where I was supposed to get a lot of yard work done. Part of the yard work was to cut the grass, but alas I suffered the lawn mower woes. You may recall in October 2013 a post that I wrote entitled “HTML Will not fix the Lawn Mower“. Continue reading The Lawn Mower Woes
Tag: Humour
HTML Will not fix the Lawn Mower
HTML will not fix the lawn mower. No matter how much I can write code, what I know will not fix my lawn mower. I checked the oil. I checked the gas. I pulled the cord of the single pull lawn mower until I had blisters and skin missing from one poor finger. Last thing to check…
Continue reading HTML Will not fix the Lawn Mower
How would you split with C-Sharp
How would you split a string with comma separated values and remove any blank records?
While the solution may seem obvious to most folks, it is not always obvious to everyone. I have been asking perspective candidates this question, but there is one common answer that I get.
“Create a loop with two array variables. Loop through the comma separated string and do substring to extract each value while keeping the current index to use as your next starting point. Then create another loop to loop through your new array of strings to add the strings with length greater than zero to a new array… then return your newest array of strings.”
That seems like a lot of loops, a lot of string arrays and a lot of thinking.
Whenever I suggest using the String object’s split command using the RemoveEmptyEntries; I get told “Oh, what I told you is probably what DotNet is doing under the hood“.
My god, that seems like a lot of work even for DotNet. I urge everyone to look at the functions available before undertaking such routines. Can you imagine the code that would be produced by a developer who is always writing code like described above? If you are unsure, use google to find your answer or even better yet use MSDN. Do not assume you know everything, because you are not expected to. There are resources around… Internet is a developer’s best friend.
Source for String Split Options: http://msdn.microsoft.com/en-us/library/ms131448.aspx