Skip to content

Instantly share code, notes, and snippets.

@matutter
Created July 11, 2014 02:57
Show Gist options
  • Save matutter/81c53c06ac4eb5a00d23 to your computer and use it in GitHub Desktop.
Save matutter/81c53c06ac4eb5a00d23 to your computer and use it in GitHub Desktop.
persistence is very easy in c#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace settings
{
public partial class Form1 : Form
{
private string variable = "...";
public Form1()
{
InitializeComponent();
label1.Text = variable = Properties.Settings.Default["variable1"].ToString() ;
}
private void button1_Click(object sender, EventArgs e)
{
variable = textBox1.Text;
updateText();
Properties.Settings.Default["variable1"] = variable;
Properties.Settings.Default.Save();
}
private void updateText()
{
label1.Text = variable;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment