I would like to help you if I could understand what you needed, sorry.
You should better explain in details what you need, give example, screenshot...etc
This way, it is really hard. Also, what is this exception thrown after validation is finished?
This may be a clue in finding a solution to your question.
I am writing a program to simulate Go Back N method. I want to open two ports(ex 9999, 8888) on one IP address (ex 127.0.0.1). But when I open 2 port on local IP address and use 2 thread to handle, one for sending(port 9999), one for receiving response(port 8888), it allways show error message. Please help me to solve this. Thank alots.
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";
} 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.
Sorry, but taking the trouble of using StringBuilder only makes sense if you succeed
in avoiding unnecessary copy operations, hence StringBuilder.Replace is not my choice at all.
Either you use String.Replace in a loop, or a one-pass populating StringBuilder.
BTW your initial values for i1 and i2 are not needed if you test after the loop (do-while).
I happen to have one here, one I wrote in C many years ago and then ported to C# a few years back, thanks for giving me a reason to revisit it. (Now I'll revisit my Split that honors quotes and escapes as well.)
subject = the string to compress
trash = list of characters to compress (usually " \b" -- SPACE and TAB)
replacements = what to replace them with (usually " " -- SPACE)
quotes = if you don't want compress within quotes, specify "\"" or "'"
escapes = not often used, but if for instance trash contains "n" and subject contains "\n"
and you don't want it replaced, specify "\\" for escapes and the "\n" will be
(quotes and escapes may be empty or null)
advanced: two characters may be specified for replacements (and I've forgotten why I allow it)
given trash="z" and replacements="xy"
then subject="zzz" becomes "yyx" (rather than "x")