I'm currently writing a project in C# (I'm new to C#, so excuse me if this is a stupid question).
When I cut the start of a string with text = var.Substring(4, var.Length - 4);, it returns a result that i don't want.
Here is a snippet of my code:
string lines = "say \"Hello, World!\"\nsay \"Hello, World!\""; lines = Regex.Split(lines, "\n"); foreach (string line in lines) { Console.WriteLine($"'{line.Substring(7, line.Length - 7)}'"); } I expect the output to be '"World!"' (two times), but this is the actual output.
'"World!" // Why is the last quote missing? '"World!"' https://stackoverflow.com/questions/65526727/removing-start-of-a-string-results-to-following-characters-replacing-it-c-shar January 01, 2021 at 09:32AM
没有评论:
发表评论