Beispiel #1
0
        public void UsingAction()
        {
            var textBox = new TextBox();

            textBox.TextChanged += delegate(string s) { Console.WriteLine("Text Changed: " + s); };

            textBox.SetText("Hello World!");
        }
Beispiel #2
0
        public void NoMemoryLeak()
        {
            var textBox = new TextBox();

            Action<string> onTextChanged = delegate(string s) { Console.WriteLine("Text Changed: " + s); };

            textBox.TextChanged += onTextChanged;

            textBox.SetText("Hello World!");

            textBox.TextChanged -= onTextChanged;
        }