c# what using?

https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/using-statement
wrapes try, finally with using statement, call the disposable method

code snippet

string manyLines=@"This is line one
This is line two
Here is line three
The penultimate line is line four
This is the final, fifth line.";

using var reader = new StringReader(manyLines);
string? item;
do {
    item = reader.ReadLine();
    Console.WriteLine(item);
} while(item != null);

No comments:

Post a Comment