How to remove specific character from a string in C#

3 Answers

0 votes
using System;

public class MyClass {
	public static void Main(string[] args)
	{
		string str = "c# c++ python c java php";

		str = str.Replace("p", String.Empty);

		Console.WriteLine(str);
	}
}





/*
run:
    
c# c++ ython c java h
    
*/

 



answered Sep 30, 2022 by avibootz
0 votes
using System;

public class MyClass {
	public static void Main(string[] args)
	{
		string str = "c# c++ python c java php";
		char ch = 'p';

		str = str.Replace(Convert.ToString(ch), String.Empty);

		Console.WriteLine(str);
	}
}





/*
run:
    
c# c++ ython c java h
    
*/

 



answered Sep 30, 2022 by avibootz
0 votes
using System;

public class MyClass {
	public static void Main(string[] args)
	{
		string str = "c# c++ python c java php";
		int ascii = 112; // 112 = 'p'

		str = str.Replace(Convert.ToString((char)ascii), String.Empty);

		Console.WriteLine(str);
	}
}





/*
run:
    
c# c++ ython c java h
    
*/

 



answered Sep 30, 2022 by avibootz
edited Sep 30, 2022 by avibootz

Related questions

1 answer 263 views
1 answer 256 views
1 answer 253 views
1 answer 285 views
3 answers 411 views
2 answers 391 views
...