Split Into Tuple - CSharp System

CSharp examples for System:String Split

Description

Split Into Tuple

Demo Code


using System.Text.RegularExpressions;
using System.Text;
using System.Linq;
using System;/*from w  ww. j  a va 2s.co  m*/

public class Main{
        public static Tuple<string, string> SplitIntoTuple(this string input, char separator)
        {
            if(input == null)
            {
                throw new ArgumentNullException("input");
            }

            var pieces = input.Split(separator);
            return Tuple.Create(pieces.FirstOrDefault(), pieces.Skip(1).FirstOrDefault());
        }
}

Related Tutorials