[英]Interface Object syntax in F#
我正在將多頁打印的C#代碼翻譯成F#。 有人可以告訴我如何翻譯:
((IAddChild)page1Content).AddChild(page1)
背景:
// printdia = printdialog
// printdoc = printdocument
// create a page
let page1 = new System.Windows.Documents.FixedPage()
page1.Width <- printdoc.DocumentPaginator.PageSize.Width
page1.Height <- printdoc.DocumentPaginator.PageSize.Height
page1.Children.Add(printcanvas) |> ignore
// add the page to the document
let page1Content = new System.Windows.Documents.PageContent()
(*C#*)((IAddChild)page1Content).AddChild(page1)
printdoc.Pages.Add(page1Content) |> ignore
// and print
printdia.PrintDocument(printdoc.DocumentPaginator, ordernr.Text);
如果page1Content.AddChild(page1)
不起作用,請嘗試(page1Content :> IAddChild).AddChild(page1)
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.