Split To Int - CSharp System

CSharp examples for System:String Split

Description

Split To Int

Demo Code

// Copyright (c) 2012 Computer Technology Solutions, Inc.  ALL RIGHTS RESERVED
using System.Text.RegularExpressions;
using System.Text;
using System.Linq;
using System.Globalization;
using System.Collections.Generic;
using System;//from www .  j ava  2 s .c  om

public class Main{
        public static IEnumerable<int> SplitToInt32(this string str, char separtor)
        {
            if (string.IsNullOrEmpty(str))
                return Enumerable.Empty<int>();
            return str.Split(new[] { separtor }, StringSplitOptions.RemoveEmptyEntries)
                .Select(x => int.Parse(x));
        }
}

Related Tutorials