Click here to Skip to main content
15,880,503 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to insert multiple values in string efficiently? Pin
Adeel Chaudhry6-May-07 4:08
Adeel Chaudhry6-May-07 4:08 
AnswerRe: How to insert multiple values in string efficiently? Pin
Luc Pattyn6-May-07 4:07
sitebuilderLuc Pattyn6-May-07 4:07 
AnswerRe: How to insert multiple values in string efficiently? Pin
AFSEKI7-May-07 2:02
AFSEKI7-May-07 2:02 
AnswerRe: How to insert multiple values in string efficiently? Pin
gumi_r@msn.com7-May-07 5:26
gumi_r@msn.com7-May-07 5:26 
QuestionStuck with Network Pin
ThanhND3076-May-07 3:23
ThanhND3076-May-07 3:23 
QuestionReduce multiple characters to one, in a string! Pin
Adeel Chaudhry6-May-07 3:18
Adeel Chaudhry6-May-07 3:18 
AnswerRe: Reduce multiple characters to one, in a string! Pin
Rob Graham6-May-07 4:03
Rob Graham6-May-07 4:03 
GeneralRe: Reduce multiple characters to one, in a string! Pin
Luc Pattyn6-May-07 4:12
sitebuilderLuc Pattyn6-May-07 4:12 
Hi,

since there may be more than 2 consecutive spaces, you need to iterate. This is how
I do this:

string s="whatever with many spaces";
do {
    int len=s.Length;
    s=s.Replace(twoSpaces, oneSpace);
} while (s.Length<len);


For very long strings with many sequences of multiple spaces, it may be more economic
to use a StringBuilder, and fill it in one pass using a bool that remembers whether last
char added was a space or not.

Smile | :)




Luc Pattyn

[My Articles]

GeneralRe: Reduce multiple characters to one, in a string! Pin
Adeel Chaudhry6-May-07 4:17
Adeel Chaudhry6-May-07 4:17 
GeneralRe: Reduce multiple characters to one, in a string! Pin
Rob Graham6-May-07 4:40
Rob Graham6-May-07 4:40 
GeneralRe: Reduce multiple characters to one, in a string! Pin
Luc Pattyn6-May-07 5:25
sitebuilderLuc Pattyn6-May-07 5:25 
GeneralRe: Reduce multiple characters to one, in a string! Pin
Adeel Chaudhry6-May-07 4:15
Adeel Chaudhry6-May-07 4:15 
AnswerRe: Reduce multiple characters to one, in a string! Pin
Guffa6-May-07 4:25
Guffa6-May-07 4:25 
GeneralRe: Reduce multiple characters to one, in a string! Pin
Adeel Chaudhry6-May-07 4:36
Adeel Chaudhry6-May-07 4:36 
GeneralRe: Reduce multiple characters to one, in a string! Pin
PIEBALDconsult6-May-07 6:52
mvePIEBALDconsult6-May-07 6:52 
AnswerRe: Reduce multiple characters to one, in a string! Pin
PIEBALDconsult6-May-07 4:41
mvePIEBALDconsult6-May-07 4:41 
GeneralRe: Reduce multiple characters to one, in a string! Pin
Adeel Chaudhry6-May-07 4:54
Adeel Chaudhry6-May-07 4:54 
GeneralRe: Reduce multiple characters to one, in a string! Pin
PIEBALDconsult6-May-07 4:57
mvePIEBALDconsult6-May-07 4:57 
AnswerRe: Reduce multiple characters to one, in a string! Pin
AFSEKI7-May-07 2:09
AFSEKI7-May-07 2:09 
QuestionTreeview challenge Pin
Rick van Woudenberg6-May-07 3:07
Rick van Woudenberg6-May-07 3:07 
AnswerRe: Treeview challenge Pin
Arun.Immanuel6-May-07 3:54
Arun.Immanuel6-May-07 3:54 
GeneralRe: Treeview challenge Pin
Rick van Woudenberg6-May-07 4:23
Rick van Woudenberg6-May-07 4:23 
JokeRe: Treeview challenge Pin
PIEBALDconsult6-May-07 5:03
mvePIEBALDconsult6-May-07 5:03 
GeneralRe: Treeview challenge Pin
Rick van Woudenberg6-May-07 9:31
Rick van Woudenberg6-May-07 9:31 
GeneralRe: Treeview challenge Pin
PIEBALDconsult6-May-07 18:18
mvePIEBALDconsult6-May-07 18:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.