w3resource
C# Sharp Programming Exercises

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

C# Sharp Exercises: 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:

Flowchart: C# Sharp Exercises - Remove specified a character from a non-empty string using index of a character

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?



New Content: Composer: Dependency manager for PHP, R Programming