次の方法で共有


ExtraTopLevelOperators.fprintf<'T> 関数 (F#)

更新 : 2010 年 5 月

fprintf 関数は、指定された書式を使用してファイルに出力します。

名前空間/モジュール パス: Microsoft.FSharp.Core.ExtraTopLevelOperators

アセンブリ: FSharp.Core (FSharp.Core.dll)

// Signature:
fprintf : TextWriter -> TextWriterFormat<'T> -> 'T

// Usage:
fprintf textWriter format

パラメーター

解説

この関数は、コンパイルされたアセンブリでは PrintFormatToTextWriter という名前です。 F# 以外の言語から、またはリフレクションを使用してこの関数にアクセスする場合は、この名前を使用します。

使用例

次の例は、fprintf の使い方を示しています。

let printNumbersToFile fileName n =
   // "use" will cause the file to be closed when it
   // goes out of scope.
   use file = System.IO.File.CreateText(fileName)
   [ 1 .. n ]
   |> List.iter (fun elem -> fprintf file "%d " elem)
   fprintfn file ""
printNumbersToFile "1to100.txt" 100

結果のファイル 1to100.txt には、次のデータが含まれています。

  

プラットフォーム

Windows 7、Windows Vista SP2、Windows XP SP3、Windows XP x64 SP2、Windows Server 2008 R2、Windows Server 2008 SP2、Windows Server 2003 SP2

バージョン情報

F# ランタイム

サポート対象: 2.0、4.0

Silverlight

サポート: 3

参照

その他の技術情報

Core.ExtraTopLevelOperators モジュール (F#)

Microsoft.FSharp.Core 名前空間 (F#)

履歴の変更

日付

履歴

理由

2010 年 5 月

コード例を追加。

情報の拡充