Pages

Men

rh

6/17/2012

String split in C#

 public String SplitStringByCase ( String inputString )
        {
            System.Text.StringBuilder sb = new System. Text. StringBuilder ( );
            sb. Append ( inputString [ 0 ] );
            for ( int i = 1; i < inputString. Length - 1; i++ )
            {
                char c = inputString [ i ];
                if ( c == ' ' )
                {
                    sb. Append ( c );
                    i++;
                    sb. Append ( Char. ToUpper ( inputString [ i ] ) );
                    continue;
                }
                if ( Char. IsUpper ( c ) )
                    sb. Append ( " " );
                sb. Append ( c );
            }
            sb. Append ( inputString [ inputString. Length - 1 ] );
            return sb. ToString ( );
        }

No comments :

Post a Comment