保留两位小数 double d; double.Parse(String.Format("{0:N}",d)); double x = double.Parse(""); double y = x % 0.01; double z = x - y;Char[] arr=TextBox1.Text.Replace(".","").ToCharArray(); arr[0]
namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void textBox1_Validated(object sender, EventArgs e) { ClearLabelText(); var numValue = this.textBox1.Text.Replace(".", ""); int j = 1; for (int i = numValue.Length-1; i >= 0; i--) { this.Controls["Label" + (j++).ToString()].Text = numValue[i].ToString(); } } private void ClearLabelText() { for (int i = 1; i < 11; i++) { this.Controls["Label" + i.ToString()].Text = string.Empty; } } } }这样行么?
double d;
double.Parse(String.Format("{0:N}",d)); double x = double.Parse("");
double y = x % 0.01;
double z = x - y;Char[] arr=TextBox1.Text.Replace(".","").ToCharArray();
arr[0]
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void textBox1_Validated(object sender, EventArgs e)
{
ClearLabelText();
var numValue = this.textBox1.Text.Replace(".", "");
int j = 1;
for (int i = numValue.Length-1; i >= 0; i--)
{
this.Controls["Label" + (j++).ToString()].Text = numValue[i].ToString();
} } private void ClearLabelText()
{
for (int i = 1; i < 11; i++)
{
this.Controls["Label" + i.ToString()].Text = string.Empty;
}
}
}
}这样行么?