Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. public static string GetLineByOffset(string text, int offset)
  2. {
  3. if (string.IsNullOrEmpty(text) || offset < 0 || offset > text.Length - 1)
  4. {
  5. return "";
  6. }
  7. var line = "";
  8. var i = offset;
  9. while (i <= (text.Length - 1) && text[i] != ('\r') && text[i] != '\n')
  10. {
  11. line = line + text[i];
  12. i += 1;
  13. }
  14. i = offset;
  15. line = line.Substring(1);
  16. while (i <= (text.Length - 1) && text[i] != ('\r') && text[i] != '\n')
  17. {
  18. line = text[i] + line;
  19. i -= 1;
  20. }
  21. return line;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement