是uint64选项类型引用类型还是值类型?我遇到了一些与此相关的性能问题。请澄清。
答案 0 :(得分:4)
由于None
隐式表示为null
,Option
是引用类型。
F#规范给出了以下定义,该选项要求选项为引用类型:
[<DefaultAugmentation(false)>]
[<CompilationRepresentation(CompilationRepresentationFlags.UseNullAsTrueValue)>]
type 'T option =
| None
| Some of 'T
static member None : 'T option
static member Some : 'T -> 'T option
[<CompilationRepresentation(CompilationRepresentationFlags.Instance)>]
member Value : 'T
member IsSome : bool
member IsNone : bool
答案 1 :(得分:0)
public class RefactorMe {
private static List<Event<Apple>> mAppleEventList = new ArrayList<Event<Apple>>();
private static List<Event<Banana>> mBananaEventList = new ArrayList<Event<Banana>>();
private static List<Event<Orange>> mOrangeEventList = new ArrayList<Event<Orange>>();
public static List<Event<Apple>> getAppleList() {
return mAppleEventList;
}
public static List<Event<Banana>> getBananaEventList() {
return mBananaEventList;
}
public static List<Event<Orange> getOrangeList() {
return mOrangeEventList;
}
public static void addAppleEvent(Event<Apple> pEvent) {
mAppleEventList.add(pEvent);
}
public static void addBananaEvent(Event<Banana> pEvent) {
mBananaEventList.add(pEvent);
}
public static void addOrangeEvent(Event<Orange> pEvent) {
mOrangeEventList.add(pEvent);
}
}
来自FSharp Source Code的表明这是一种参考类型。