Deserializes the string into a string[] - CSharp System

CSharp examples for System:String Split

Description

Deserializes the string into a string[]

Demo Code



public class Main{
        /// <summary>
        /// Deserializes the string into a string[]
        /// </summary>
        /// <param name="obj">String to deserialize</param>
        /// <param name="separator">Separator</param>
        /// <returns>String array</returns>
        public static string[] Deserialize(this string obj, char separator)
        {/*from   w ww.j a  va  2s .  c o  m*/
            return string.IsNullOrEmpty(obj) ? null : obj.Split(separator);
        }
        /// <summary>
        /// Deserializes the string into a string[] having a ";" as a separator
        /// </summary>
        /// <param name="obj">String to deserialize</param>
        /// <returns>String array</returns>
        public static string[] Deserialize(this string obj)
        {
            return Deserialize(obj, ';');
        }
}

Related Tutorials