Last active
August 29, 2015 13:57
-
-
Save Yunanw/9443636 to your computer and use it in GitHub Desktop.
ReadUntil
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String ReadUntil(this StreamReader reader, char delimeter) | |
{ | |
StringBuilder sb = new StringBuilder(); | |
char c; | |
while ((c = (char)reader.Read()) != 0) | |
{ | |
if (c == delimeter) | |
return sb.ToString(); | |
else | |
sb.Append(c); | |
} | |
return sb.Length == 0 ? null:sb.ToString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
从流中读取字符,直到遇到一个特定的字符