'How delete a selected character on the texbox [duplicate]
I can't make a code to delete a selected character on the texbox. Example: I would remove ",H" "H,t,I,P,H,A,P" Result: "H,t,I,P,A,P" (only 1 ",H" must be removed) I tried with Contains and remove does not work no other that I have found
string source = Texbox.Text;
if (source.Contains(',H'))
{
source.Replace(",H", "");
}
Does not work at all. Is there anyone who can help me?
Solution 1:[1]
If you want to remove in general an H then this:
string MyString = "Hello World!"; char[] MyChar = {'e', 'H','l','o',' ' }; string NewString = MyString.TrimStart(MyChar); Console.WriteLine(NewString);
otherwise you loop throught locate its index and use this :
string MyString = "Hello Beautiful World!"; Console.WriteLine(MyString.Remove(5,10)); // The example displays the following output: // Hello World!
in your case:
Console.WriteLine(Texbox.Text.Remove(9,1));
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Maher salah |
