移除数字文本中前面的0
public string remove(string result) {
string[] list = result.Split('');
int length = list.Length;
string s = "";
for (int i = 0; i < length; i++) {
if (list[i].Equals("0")) {
continue;
}
s += list[i];
}
return s == "" ? "0" : s;
}
–
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace com.sdust.language.calculate {
public partial class CalculateForm : System.Windows.Forms.Form {
public CalculateForm() {
InitializeComponent();
}
public void CalculateForm_Load(object sender, EventArgs e) {
}
/**
* 当前参与运算的数据或者运算的结果
*/
public string express = "";
private void Number_Click(object sender, EventArgs e) {
Button num = sender as Button;
express += num.Text;
this.Express.Text = express;
}
public decimal AnalyseExpress() {
if (express.Length<=3) {
return 0;
}
string[] list = express.Split();
return 0;
}
private void Plus_Click(object sender, EventArgs e) {
Button num = sender as Button;
switch (num.Text) {
case "+":
break;
case "-":
break;
case "*":
break;
case "/":
break;
default:
break;
}
}
}
}
public static void Main(string[] args) {
int i = 1;
int j = 0;
int k = 1;
try {
k = i / j;
} catch (Exception) {
Console.WriteLine("除数不可为零");
} finally {
}
}
private int _id;
public int Id {
get {
return _id;
}
set {
_id = value;
}
}
Student student = new Student();
student.Id = 1;
int id = student.Id;
Console.WriteLine(id);