我试图在 label1
上显示货币汇率,但我不知道应该在 label1.Text =
中输入什么。那么有人可以指导我吗
String[] arr = new string[2];
arr[0] = "US"
arr[1] = "SG"
Combobox1.Items.AddRange(arr);
Combobox2.Items.AddRange(arr);
在 combobox1
和 combobox2
中
double[,] value = new double [2,2];
for(int I =0; I<2; I++)
{
value[0,0] = 1; // basically if I chose Combobox1 US and Combobox2 US the rate is 1;
value[0,1] = 1.24; // US to SG
value[1,0] = 0.80; // SG to US
value[1,1] = 1; // SG to SG
Label1.Text =
}
最佳答案
我假设您想打印出值(1、1.24、0.08 或 1)。
您可以做的是创建一个变量并使用 if 语句设置它的值,然后在 Label1 中打印该值
double labelValue;
if (value[0,0]) labelValue = 1;
else if (value[0,1]) labelValue = 1.24;
else if (value[1,0]) labelValue = 0.80;
else if (value[1,1]) labelValue = 1;
Label1.Text = labelValue;
关于C# for 组合框中的循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17791119/