我有一个包含字符串和双精度的字典 myDataItems。我将值从 2 个文本框传递给字典,1 个文本框传递字符串值,另一个传递双精度值。我想知道如何在我用于输出目的的第三个文本框(txtOutput)中显示字典项目?
public partial class Form1 : Form
{
private Dictionary<string, double> myDataItems = new Dictionary<string, double>();
private string dataName;
private double dataCost;
private void dataItemSend_Click(object sender, EventArgs e)
{
dataName = dataNameInput.Text;
dataCost = Convert.ToDouble(dataCostInput.Text);
myDataItems.Add(dataName, dataCost);
txtOutput.Text = myDataItems.ToString();
}
}