什么是在.NET中的使用值类型的? [英] What's the use of value types in .Net?

查看:109
本文介绍了什么是在.NET中的使用值类型的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

href="http://msdn.microsoft.com/en-us/library/y23b5415.aspx" rel="nofollow"> 表明,有可能是非常少的实际用途的官方指南的

The official guidelines suggest that there can be very few practical uses for these. Does anyone have examples of where they've put them to good use?

推荐答案

在大多数情况下,这是很好的模拟框架的行为。许多基本数据类型,如 INT 是值类型。如果您有具有类似性质的类型,使用的值类型。例如,写一个时复杂的数据类型或的BigInteger ,价值类型是合理的解决方案。这同样适用于那里的框架中使用的值类型的其他情形:的DateTime

For the most part, it's good to emulate the behaviour of the framework. Many elementary data types such as ints are value types. If you have types that have similar properties, use value types. For example, when writing a Complex data type or a BigInteger, value types are the logical solution. The same goes for the other cases where the framework used value types: DateTime, Point, etc.

如果有疑问,可以使用一个引用类型来代替。

When in doubt, use a reference type instead.

这篇关于什么是在.NET中的使用值类型的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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