Say what you will about VB, it does have some wrappers for some neat functions. One of my favorites is the Split function. Essentially, it takes a string, a parse character parameter, and returns a string array of the items. For example, it might look like string[] mystring = Split(myCommaDelimitedString,”,”);
So here's what the code looks like:
/// <summary> /// Replacement in C# of the VB.Net split function /// </summary> /// <param name="baseString">string to parse</param> /// <param name="splitChar">chanracter to parse with </param> /// <returns></returns> public static string[] Split(string baseString, string splitChar) { char[] sep = {(splitChar.ToCharArray())[0]}; return baseString.Split(sep); }
Now, I know you can use the string object's split functionality to do the same thing. However, those coming out of the VB world will appreciate the encapsulation, as well as never having to remember the syntax for pre-defining a character array.
Powered by: newtelligence dasBlog 2.3.9074.18820
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2012, © Copyright 2010
E-mail