I have a dictionary myDataItems which contains string and double. I’m passing values to the dictionary from 2 textboxes, 1 textbox passes the string value, the other the double. I was wondering how I can get the Dictionary items displayed in a 3rd textbox(txtOutput) I’m using for output purposes?
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();
}
}
A simple approach:
Remember to add
using System.Linq;