C# 去除数值后面多余的0

/*
 * 由SharpDevelop创建。
 * 用户: Administrator
 * 日期: 2019/08/28
 * 时间: 09:38
 * 
 * 去除数值后面多余的0
 * 
 * 
 * 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
 */
using System;
using System.Text.RegularExpressions;


namespace test1
{
	class Program
	{
		public static void Main() 
		{
			string str =Console.ReadLine();
			Console.WriteLine(strs(str));
			Console.ReadKey();
		}

		private static string strs(string str) 
		{
			if (str.IndexOf(".") > 0) {
				str =Regex.Replace(str.Trim(),"0+?$", " ");
				str =Regex.Replace(str.Trim(),"[.]$", " ");
			}			
			return str;
		}

	// Scanner s=new Scanner(System.in);
	// String str=s.next().toString();
	// String [] arr=str.split(",");
	// String[] number=new String[arr.length];
	// for(int i=0;i

 

你可能感兴趣的:(C#)