本文整理匯總了VB.NET中System.Console.Out屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET Console.Out屬性的具體用法?VB.NET Console.Out怎麽用?VB.NET Console.Out使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Console
的用法示例。
在下文中一共展示了Console.Out屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Example
' 導入命名空間
Imports System.IO
Module Example
Public Sub Main()
' Get all files in the current directory.
Dim files() As String = Directory.GetFiles(".")
Array.Sort(files)
' Display the files to the current output source to the console.
Console.WriteLine("First display of filenames to the console:")
Array.ForEach(files, Function(s) WriteOutput(s))
Console.Out.WriteLine()
' Redirect output to a file named Files.txt and write file list.
Dim sw As StreamWriter = New StreamWriter(".\Files.txt")
sw.AutoFlush = True
Console.SetOut(sw)
Console.Out.WriteLine("Display filenames to a file:")
Array.ForEach(files, Function(s) WriteOutput(s))
Console.Out.WriteLine()
' Close previous output stream and redirect output to standard output.
Console.Out.Close()
sw = New StreamWriter(Console.OpenStandardOutput())
sw.AutoFlush = True
Console.SetOut(sw)
' Display the files to the current output source to the console.
Console.Out.WriteLine("Second display of filenames to the console:")
Array.ForEach(files, Function(s) WriteOutput(s))
End Sub
Private Function WriteOutput(s As String) As Boolean
Console.Out.WriteLine(s)
Return True
End Function
End Module