2013-07-14 287 views
-1

我正在處理C#應用程序,並且我有一個字符串變量具有多個單詞。我需要的是從它中讀出所有的單詞,並將它們變成一個,沒有空格。將字符串中的單詞連接成單個字符串

字符串例如= "One Two Three Four"

字符串,我想= "OneTwoThreeFour"

有沒有在C#中,做這樣的功能?

+1

'System.Text.RegularExpressions.Regex.Replace()'? – NINCOMPOOP

+0

爲什麼我的帖子被拒絕? – chiapa

回答

2
String concatenatedString = example.Replace(" ", String.Empty); 
+0

謝謝,那就是我一直在尋找的東西。 – chiapa

2

這樣做;

word = word.Replace(" ",""); 
1

試試這個:

String example = "One Two Three Four"; 
string str = example.Replace(" ",string.Empty); 
相關問題