在C#中,可以用Keys.Control | Keys.M
的形式表示KeyPress
事件的字符。在F#中,Keys.Control ||| Keys.M
不起作用。什麼?如何在F#中表達(Keys.Control | Keys.M)?
編輯:確實很有意思。根據JohannesRössel在F#交互式窗口中的建議使用System.Windows.Forms.Keys.Control ||| System.Windows.Forms.Keys.M
完全按照他的說法工作。將其寫入.fs文件:
form.KeyPress.Add (fun e ->
if (e.KeyChar = (System.Windows.Forms.Keys.Control ||| System.Windows.Forms.Keys.M)) then textbox.SelectAll())
給我錯誤The type 'char' does not support any operators named '|||'
。所以我可能錯誤地標識了問題的位置。沒有從Keys
到字符的類型轉換。
「不工作」非常模糊。也許你可以改爲發佈特定的錯誤。 – Gian 2010-08-14 22:51:08