// Create an object and do not dispose of it.
 private void createButton_Click(object sender, EventArgs e)
 {
     // Make an object.
     DisposableClass obj = new DisposableClass();
     obj.Name = "Create " + ObjectNumber.ToString();
     ObjectNumber++;
 }
Beispiel #2
0
        // Create an object and do not dispose of it.
        private void createButton_Click(object sender, EventArgs e)
        {
            // Make an object.
            DisposableClass obj = new DisposableClass();

            obj.Name = "Create " + ObjectNumber.ToString();
            ObjectNumber++;
        }
        // Create an object and dispose of it.
        private void createAndDisposeButton_Click(object sender, EventArgs e)
        {
            // Make an object.
            DisposableClass obj = new DisposableClass();
            obj.Name = "CreateAndDispose " + ObjectNumber.ToString();
            ObjectNumber++;

            // Dispose of the object.
            obj.Dispose();

            // Version that uses using.
            // Make an object.
            //using (DisposableClass obj = new DisposableClass())
            //{
            //    obj.Name = "CreateAndDispose " + ObjectNumber.ToString();
            //    ObjectNumber++;
            //}
        }
Beispiel #4
0
        // Create an object and dispose of it.
        private void createAndDisposeButton_Click(object sender, EventArgs e)
        {
            // Make an object.
            DisposableClass obj = new DisposableClass();

            obj.Name = "CreateAndDispose " + ObjectNumber.ToString();
            ObjectNumber++;

            // Dispose of the object.
            obj.Dispose();

            // Version that uses using.
            // Make an object.
            //using (DisposableClass obj = new DisposableClass())
            //{
            //    obj.Name = "CreateAndDispose " + ObjectNumber.ToString();
            //    ObjectNumber++;
            //}
        }