gpt4 book ai didi

c# - C# default 关键字在 F# 中的等价物是什么?

转载 作者:IT王子 更新时间:2023-10-29 03:42:30 25 4
gpt4 key购买 nike

我正在寻找 C# default 关键字的等价物,例如:

public T GetNext()
{
T temp = default(T);
...

谢谢

最佳答案

我在博客中找到了这个:“What does this C# code look like in F#? (part one: expressions and statements)

C# has an operator called "default" that returns the zero-initialization value of a given type:

default(int) 

It has limited utility; most commonly you may use default(T) in a generic. F# has a similar construct as a library function:

Unchecked.defaultof<int>

关于c# - C# default 关键字在 F# 中的等价物是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2246206/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com