- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
c# Put spaces between words starting with capital letters
To place spaces in between words starting with capital letters, try the following example −
Firstly, set the string.
var str = "WelcomeToMyWebsite";
As you can see above, our string isn’t having spaces before capital letter. To add it, use LINQ as we have done below −
str = string.Concat(str.Select(x => Char.IsUpper(x) ? " " + x : x.ToString())).TrimStart(' ');
The following is the complete code to place spaces between words beginning with capital letters −
Example
using System; using System.Linq; class Demo { static void Main() { var str = "WelcomeToMyWebsite"; Console.WriteLine("Original String: "+str); str = string.Concat(str.Select(x => Char.IsUpper(x) ? " " + x : x.ToString())).TrimStart(' '); Console.WriteLine("New String: "+str); Console.ReadLine(); } }
- Related Articles
- Regex in Python to put spaces between words starting with capital letters
- Setting Spaces between Letters with CSS letter-spacing Property
- MySQL update query to remove spaces between letters?
- Program to rearrange spaces between words in Python
- How to find capital letters with Regex in MySQL?
- How to input letters in capital letters in an edit box in Selenium with python?
- Maximum Score Words Formed by Letters in C++
- How to put space between words that start with uppercase letter in string vector in R?
- Given below is a crossword puzzle based on this lesson. Use hints to fill in the blank spaces with letters that complete the words."\n
- Python Program that extract words starting with Vowel From A list
- How to set the font to be displayed in small capital letters with JavaScript?
- Fetch only capital words from DataFrame in Pandas
- Move string capital letters to front maintaining the relative order - JavaScript
- Difference between working capital and fixed capital.
- Interchanging first letters of words in a string in JavaScript

Advertisements