Camel Friendly - CSharp System

CSharp examples for System:String Case

Description

Camel Friendly

Demo Code


using Microsoft.Extensions.Localization;
using System.Text.RegularExpressions;
using System.Text;
using System.Net;
using System.Linq;
using System.Globalization;
using System.Collections.Generic;
using System;//from   w ww.  j  a va2  s . c o  m

public class Main{
        public static string CamelFriendly(this string camel)
        {
            if (string.IsNullOrWhiteSpace(camel))
                return "";

            var sb = new StringBuilder(camel);

            for (int i = camel.Length - 1; i > 0; i--)
            {
                var current = sb[i];
                if ('A' <= current && current <= 'Z')
                {
                    sb.Insert(i, ' ');
                }
            }

            return sb.ToString();
        }
}

Related Tutorials