How to remove char from a string by index in C#

1 Answer

0 votes
using System;
using System.Text;

class Program
{
    static string string_char_remove(string s, int idx) { 
        int len = s.Length; 
 
        StringBuilder sb = new StringBuilder(s);
        
        sb.Remove(idx, 1);
        
        return sb.ToString();
    } 
    static void Main() {
        string s = "c# programming"; 
 
        s = string_char_remove(s, 3);

        Console.Write(s);
    }
}




/*
run:

c# rogramming

*/

 



answered Nov 16, 2019 by avibootz

Related questions

1 answer 167 views
1 answer 146 views
1 answer 148 views
1 answer 115 views
115 views asked Feb 28, 2023 by avibootz
3 answers 363 views
2 answers 311 views
...