Example #1
0
        private void WriteLines(IEnumerable <string> lines)
        {
            using var file = new MyFile("test.txt");

            foreach (var line in lines)
            {
                file.WriteLine(line);
            }

            myFile = file;
        } //is disposed
Example #2
0
        private void WriteLines(IEnumerable <string> lines)
        {
            //não precisa mais usar o using no contexto
            using var file = new MyFile("test.txt");

            foreach (var line in lines)
            {
                file.WriteLine(line);
            }

            myFile = file;
        }