Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace tests1
- {
- class Program
- {
- static void Main(string[] args)
- {
- var s = new S(); //здесь все в порядке
- using (s)
- {
- Console.WriteLine(s.GetDispose());
- }
- Console.WriteLine(s.GetDispose());//и здесь все в порядке
- Console.ReadKey();
- }
- }
- public struct S : IDisposable
- {
- private bool dispose; //значение bool по умолчанию равно false. А метод Dispose не вызывается. Поэтому вывод: false, false
- public void Dispose()
- {
- dispose = true;
- }
- public bool GetDispose()
- {
- return dispose;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment