- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
在 F# 中,我们可以创建这样的函数:
let ``add x and y`` x y = x + y
我通常可以这样调用它:
``add x and y`` 1 2
有没有办法从 C# 端调用上面的函数?不过,我什至无法在对象浏览器中看到它。
最佳答案
您可以公开任何 valid F# 函数名称到 C# 作为任何 C# 有效函数名称使用 CompiledName属性:
namespace Library1
module Test =
[<CompiledName("Whatever")>]
let ``add a and b`` x y = x + y
然后在 C# 中:
using Library1;
...............
System.Console.WriteLine(Test.Whatever(2,2));
跟进 03/05/2016 来自 NickL 的评论, 至少适用于 F#3.1:
从函数转移到成员会带来一些“如果和但是”。
首先,如果从纯命名空间
使用,CompiledName
属性不会与member
一起编译。单纯的编译需要在 module
中使用。
当在 module
中使用并修饰 F# record 的 method member
时,无论两个刻度之间的内容看起来如何,它都可以正常工作.但是,当装饰 property member
时,F# 记录 CompiledName
仅当双刻度之间的内容类似于some 时才可见交叉汇编合法值名称:
module M
type MyRecord =
{ myField: string }
[<CompiledName "Whatever">]
member x.``Blah Blah blah``() = x.myField
[<CompiledName "Another">]
member x.``ABC`` = x.myField
然后在 C# 中以下工作正常:
var recInC = new M.MyRecord("Testing...");
Console.WriteLine(recInC.Whatever());
Console.WriteLine(recInC.Another);
这种不一致提示潜在的 issues .
关于c# - 从 C# 调用带有嵌入空格 (`` XXX YY`` 的 F# 勾选函数名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19327506/
我正在构建一个自定义复选框,功能已经差不多了,但样式还有待改进。 我有几个问题, 我需要以圆为中心的支票 我只需要在单击复选框本身而不是文本时激活检查。 恐怕我无法在不使用左侧位置左侧的填充的情况下将
您好,我正在使用 Titanium 创建一个可以检查的行表。 我需要用 Javascript 编写一些代码,只允许检查一行,当检查其中一行时,其他行则取消检查。 我不担心 Titanium 部分,但更
我需要你的帮助。 如何从数组中获取值并使用 HTML 5 的 data 属性选中(勾选)其相关复选框? 即。 var x = "[monday,thursday]" ...经过一些处理后
我在 Winforms 应用程序中有一个 CheckedListBox,其中包含月份作为项目(如一月、二月、三月等)我正在尝试实现这样的功能,即当任何项目被选中时,应该弹出一条消息,说明它已被选中。而
我是一名 iOS 开发新手。我想在我的 UITableViewCell 被选中时添加一个复选标记。选择另一行时,应删除复选标记。我该怎么做? 最佳答案 不要使用 [tableview reloadDa
在我的应用程序中,有 2 个复选框用于获取用户的类型(例如:学生或教师)。我知道我应该使用单选按钮而不是复选框,但我在教程中的问题要求使用复选框(所以请暂时忽略单选按钮)。 即使我选中一个复选框,is
我的 html 页面上有一个表单,其中有一堆复选框作为选项。其中一个选项是“全选”,我希望在选中“全选”框后立即选中所有其他复选框(如果未选中)。我的代码看起来像这样: All Posts
我有一个 JSP,我在其中使用 c:out 打印一些字符串。但我需要通过反斜杠转义所有 '(刻度)。 示例:jsp '"> 打印 tag.title = test's 'test's 但我
我有一个复选框,然后是一个交叉图像,如下所示。 当我单击图像时,复选框应该被选中。我尝试了以下代码。但没有用。 任何人都可以帮助使用 Javascript 来完成它... 最佳答案 你可以使用jQu
我对使用 python 做一个编程游戏很感兴趣,并且我想以 GunTactyx ( http://apocalyx.sourceforge.net/guntactyx/index.php ) 的风格来
我正在使用 UltimateListCtrl 和 LC_LIST 样式。我的列表中的所有项目都带有复选框。填充列表后,我尝试根据从数据库收到的数据动态检查(勾选)一些项目。但在填充列表后,我无法检查(
这个问题在这里已经有了答案: .prop() vs .attr() (18 个答案) 关闭 9 年前。 我已经看过,但无法为我的问题找到简单的答案。我单击其中一个 TR,然后单击另一个 TR,它工作
我有这个 HTML 代码: 如何在 JavaScript 中检查(勾选)值“2”?我无法更改 html 代码,它是公共(public)网站。这是此 radio 的 XPath,值为“2” //*[
请考虑这段代码: plotOptions: { series: { label: { connectorAllowed: false }
我是一名优秀的程序员,十分优秀!