Skip to content

Instantly share code, notes, and snippets.

@YurePereira
Created April 15, 2024 03:33
Show Gist options
  • Select an option

  • Save YurePereira/3ffe573b208213b889f9d2794a5353f9 to your computer and use it in GitHub Desktop.

Select an option

Save YurePereira/3ffe573b208213b889f9d2794a5353f9 to your computer and use it in GitHub Desktop.
Garanta que seus objetos que lidam com um uso maior de alocamento de memória sejam descartados corretamente utilizando a instrução using, fazendo com que suas aplicações tenham maior desempenho.
Melão 🍈 (Melon)
Coco 🥥 (Coconut)
Manga 🥭 (Mango)
Banana 🍌 (Banana)
Pera 🍐 (Pear)
Kiwi 🥝 (Kiwi)
using System;
using System.IO;
public class Program
{
public static void Main()
{
using (StreamReader reader = File.OpenText("conteudo.txt"))
{
string linha;
while ((linha = reader.ReadLine()) != null)
{
Console.WriteLine("Fruta:" + linha);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment