Join Verbatim String - CSharp System

CSharp examples for System:String Join

Description

Join Verbatim String

Demo Code


using System.Text.RegularExpressions;
using System.Linq;
using System;/*  www . j  av a2s  . c o m*/

public class Main{
        public static string JoinVerbatim(this string s)
        {
            return string.Join("", s.Split(new[] {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries)
                                    .Select(x => x.TrimVerbatim()));
        }
        public static string TrimVerbatim(this string s)
        {
            var r = new Regex(@"^\s+", RegexOptions.Multiline);
            return r.Replace(s, string.Empty);
        }
}

Related Tutorials