遵循代码C#:
var body = new CustomerRequest
{
Method = "CREDIT_CARD",
CreditCard = new Creditcard
{
ExpirationMonth = "06",
ExpirationYear = "2022",
Number = "4012001037141112",
Cvc = "123"
}
};
我是F#的新手,我无法实例化C#之类的类,请参见F#中的以下代码:
let body = CustomerRequest
(
Method = "CREDIT_CARD" // Help here
)
我无法将C#转换为F#
最佳答案
如果只想使用named arguments设置要构造的类的属性:语法与C#非常相似。至于缩进级别,您需要与第一个参数的对齐方式保持一致。
let body =
CustomerRequest(
Method = "CREDIT_CARD",
CreditCard =
Creditcard(
ExpirationMonth = "06",
ExpirationYear = "2022",
Number = "4012001037141112",
Cvc = "123" ) )