当我们总是使用可空值类型而不是值类型时,是否存在性能下降?
解决方法@H_404_4@
正如
Mitch Wheat所指出的那样,不,你不应该担心这一点.我现在要给你简短的答案理由,后来我会帮助你发现更多关于你所问的问题:
Write your code to be correct. Profile after writing so that you find the points that are causing you grief.
如果您的代码经常使用Nullable并且您有性能原因并且您对其进行了分析并且您自己无法找到问题,那么请问我们如何更快地使用它.但不,使用Nullable的开销是用于所有意图和目的而不是降级.
详细了解您的要求:
> Performance surprise with “as” and nullable types
> Why shouldn’t I always use nullable types in C#
> C# Performance gain returning a Nullable Type from a SqlDataReader
> Alternatives to nullable types in C#
> Casting (int?)null vs. new int?() – Which is better?
> Boxing / Unboxing Nullable Types – Why this implementation?
现在,阅读完所有这些页面后,我希望你能感受到更多的启发.
Write your code to be correct. Profile after writing so that you find the points that are causing you grief.
如果您的代码经常使用Nullable并且您有性能原因并且您对其进行了分析并且您自己无法找到问题,那么请问我们如何更快地使用它.但不,使用Nullable的开销是用于所有意图和目的而不是降级.
详细了解您的要求:
> Performance surprise with “as” and nullable types
> Why shouldn’t I always use nullable types in C#
> C# Performance gain returning a Nullable Type from a SqlDataReader
> Alternatives to nullable types in C#
> Casting (int?)null vs. new int?() – Which is better?
> Boxing / Unboxing Nullable Types – Why this implementation?
现在,阅读完所有这些页面后,我希望你能感受到更多的启发.