C# Sharp Exercises: Remove specified a character from a non-empty string using index of a character
C# Sharp Basic: Exercise-15 with Solution
Write a C# program remove specified a character from a non-empty string using index of a character
Sample Solution:
C# Sharp Code:
using System;
using System.Collections.Generic;
public class Exercise15 {
static void Main(string[] args)
{
Console.WriteLine(remove_char("w3resource", 1));
Console.WriteLine(remove_char("w3resource", 9));
Console.WriteLine(remove_char("w3resource", 0));
}
public static string remove_char(string str, int n)
{
return str.Remove(n, 1);
}
}
Test Data: w3resource
Sample Output:
wresource w3resourc 3resource
Flowchart:
C# Sharp Code Editor:
Improve this sample solution and post your code through Disqus
Previous: Write a C# Sharp program to convert from celsius degrees to Kelvin and Fahrenheit.
kelvin = celsius + 273
Next: Write a C# program to create a new string from a given string where the first and last characters will change their positions
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework