Skip to content

Instantly share code, notes, and snippets.

@Yunanw
Last active August 29, 2015 13:57
Show Gist options
  • Save Yunanw/9443636 to your computer and use it in GitHub Desktop.
Save Yunanw/9443636 to your computer and use it in GitHub Desktop.
ReadUntil
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();
}
@Yunanw
Copy link
Author

Yunanw commented May 6, 2014

从流中读取字符,直到遇到一个特定的字符

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment