How to remove the second digit from a number in C#

1 Answer

0 votes
using System;

public class Program
{
	public static int remove_second_digit(int n) {
		string str = Convert.ToString(n);

		str = str.Substring(0, 1) + str.Substring(2);

        return int.Parse(str);
    }
    
	public static void Main(string[] args)
	{
		int n = 87315;
		
		n = remove_second_digit(n);

		Console.WriteLine(n);
	}
}




/*
run:
  
8315
  
*/

 



answered Jan 12, 2024 by avibootz
edited Jan 13, 2024 by avibootz

Related questions

1 answer 169 views
1 answer 107 views
1 answer 143 views
1 answer 111 views
1 answer 144 views
1 answer 111 views
1 answer 104 views
...