How to remove the last N characters from a string in C#

1 Answer

0 votes
using System;

public class RemoveLastNCharacters_CSharp
{
	public static void Main(string[] args)
	{
		string s = "c# programming";

		int N = 4;
		s = s.Substring(0, s.Length - N);

		Console.WriteLine(s);
	}
}


/*
run:
       
c# program
    
*/

 



answered Sep 12, 2024 by avibootz

Related questions

2 answers 188 views
2 answers 213 views
1 answer 100 views
1 answer 125 views
1 answer 128 views
1 answer 152 views
1 answer 84 views
...