FSharpChoice在C# [英] FSharpChoice in C#

查看:128
本文介绍了FSharpChoice在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 FSharpChoice 键入一个C#项目。我创建了一个选择,像这样

I am trying to use FSharpChoice type in a C# project. I have created a choice like so

var a = FSharpChoice<T1,T2,T3>.NewChoice1Of3(instofT1);

现在我如何获得 instofT1 出选择类型。

now how do I get instofT1 out of the choice type.

我知道我可以做一个 IsChoice1Of3 ,但我如何获得在选择对象的价值?

I see I can do a IsChoice1Of3 but how do i get to the value in the choice object?

推荐答案

值转换为 FSharpChoice< T1,T2,T3> .Choice1Of3 并使用项目属性。

请参阅的从其他CLI语言在F#规范有关如何更多信息,使用联合类型的编译形式歧视工会的代表。

See Compiled Form of Union Types for Use from Other CLI Languages in the F# spec for more information about how discriminated unions are represented.

这篇关于FSharpChoice在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆