F#使用HttpPostedFileBase(抽象类作为成员类型)

时间:2015-03-18 18:23:04

标签: c# asp.net asp.net-mvc f#

我一直在将我的MVC模型/表单从C#转换为F#库,但似乎无法解决这个问题。我在原始C#模型中使用HttpPostedFileBase,但我很困惑如何编写一个以类似方式工作的F#类型。

// C#
public class UploadForm()
{
    public int ItemID { get; set; }
    public string Email { get; set; }
    public HttpPostedFileBase UploadFile { get; set; }
    // UploadFile is the name of the HTML file input on the Razor view
}
// F#
type UploadForm() = 
    member val ItemID = 0 with get, set
    member val Email = "" with get, set
    member val UploadFile = ???

我在abstract properties上阅读了F#文档,但我没有在这里覆盖任何属性......只是试图说某个成员(UploadFile)应该是某种类型(HttpPostedFileBase)。这是可能的还是我需要编写支持代码?

1 个答案:

答案 0 :(得分:0)

你可以用通常的方式给出一个类型:

type UploadForm() = 
    // ... other members
    member val UploadFile : HttpPostedFileBase = null with get, set
相关问题