using System;
using System.IO;
class Program
{
static void Main()
{
string line = "";
StreamReader sr = new StreamReader(@"C:\test.txt");
try
{
while ((line = sr.ReadLine()) != null)
{
Console.WriteLine(line);
}
}
finally
{
sr.Dispose();
}
Console.ReadKey();
}
}
|
Imports System.IO
Class Program
Private Shared Sub Main()
Dim line As String = ""
Dim sr As New StreamReader("C:\test.txt")
Try
While (InlineAssignHelper(line, sr.ReadLine())) IsNot Nothing
Console.WriteLine(line)
End While
Finally
sr.Dispose()
End Try
Console.ReadKey()
End Sub
Private Shared Function InlineAssignHelper(Of T)(ByRef target As T, value As T) As T
target = value
Return value
End Function
End Class
|