I am trying to trim a string using String.Trim
split[2].Trim(';')
but I get the result:
System;
instead
System
I also tried using
split[2].TrimEnd(';')
but it still returns the same result.
Also if i do
split[2].Trim('S', ';')
I get
ystem;
I am really confused why this is happening. Maybe because the semicolon is not the last character in the string?
Here is the complete code:
string line = @" using System; using System.Windows.Forms; class HelloWorld { static void Main() { #if DebugConfig Console.WriteLine("WE ARE IN THE DEBUG CONFIGURATION"); #endif Console.WriteLine("Hello, world!"); DialogResult result; result = MessageBox.Show("Itsyeboi", "Yup", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { Console.WriteLine("Yes"); Console.ReadLine(); } else { Console.WriteLine("No"); Console.ReadLine(); } } }" string[] split = line.Split(' ', '\n'); while (true) { if (split[counter4] == "using") { richTextBox1.Text = split[1].Trim(';'); break; } else { richTextBox1.Text = line; break; } }
FYI I recently saw a comment that noticed that my while loop makes no sense. True, but this is "WIP", not the final version.
source share