Get Results String With Hyphen - CSharp System

CSharp examples for System:String Format

Description

Get Results String With Hyphen

Demo Code


using System.Text.RegularExpressions;
using System.Security;
using System.Runtime.InteropServices;
using System;//from   ww  w.  ja  v  a 2s. co m

public class Main{
        public static string GetResultsWithHyphen(string input)
        {
            var output = "";
            var start = 0;

            while (start < input.Length)
            {
                output += input.Substring(start, Math.Min(6, input.Length - start)) + "-";
                start += 6;
            }

            return output.Trim('-');
        }
}

Related Tutorials