C# 检查字符串读取器的行号
如何检查字符串读取器是否已通过某个行号,或者是否已通过包含某些文本的行号?我将其放入字符串读取器的行处理代码中:
if (currentline.Contains("123"))
currentbank = "123";
else if (currentline.Contains("456"))
currentbank = "456";
else if (currentline.Contains("789"))
currentbank = "789";
我想根据字符串所在的行号范围来更改字符串的内容,用我的代码它总是给出 123。例如,如果它来自第 10 行- 20(或从 123 到 456),那么字符串应该有 123、20-30(或 456 到 789),它应该有 456,而 30-40 有 789。我如何使用 StringReader 来做到这一点?
How do I check if the string reader has passed a certain line number, or has passed a line number which contains some text? I put this in the line processing code of a string reader:
if (currentline.Contains("123"))
currentbank = "123";
else if (currentline.Contains("456"))
currentbank = "456";
else if (currentline.Contains("789"))
currentbank = "789";
I want to change the contents of a string based on what range of line numbers it is in, with my code it always gives 123. Like for example if it's from lines 10-20 (or from 123 to 456) then the string should have 123, 20-30 (or 456 to 789) it should have 456 and 30-40 have 789. How can I do this using a StringReader
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我自己修复了它,问题是我使用大写(例如 TEST)而不是小写。
Fixed it myself, problem being I used upper case (e.g. TEST) instead of lower case.