任何限制的属性数量上的.NET类? [英] Any limit to number of properties on a .NET Class?
问题描述
接到规格超过800属性添加到一个对象。是他们的任何限制为属性的数量对象可以在C#(或.NET)?
Received a spec to add over 800 properties to an object. Is their any 'limits' to the number of Properties an object can have in C# (or .NET)?
时的任何性能影响与问候关心这一类的对象有这么多属性?
Is their any performance impacts to be concerned with in regards to objects of this class with this many properties?
谢谢!
推荐答案
该元数据可以有多达24位的参考/每个组件的定义。作为一个属性,则需要每财产2种方法。因此,限制将是23位,或 1<< 23日 - 1
整个组装
The metadata can have up to 24-bit references/definitions per assembly. Being a property, you need 2 methods per property. Hence the limit will be 23-bit, or 1 << 23 - 1
for the entire assembly.
更新:
如果他们只是只读属性,极限是 1&LT;&LT; 24日 - 1
If they are only read-only properties, the limit would be 1 << 24 - 1
.
答到第二个问题:
没有,不会有性能开销。简单的特性很可能由JIT内联。
No, there will be no performance overhead. Simple properties are likely to be inlined by the JIT.
的几点思考:
您将永远不会达到上述限制。有1600万特性成像。这将需要保存的名称太1600万串。假设平均名称为8个字符,那么你正在寻找〜256MB(属性名+方法名)的字符串表的大小,然后您还没有甚至开始编码呢。只是一个想法。
You will never reach the above limit. Imaging having 16 million properties. That will require 16 million strings stored for the names too. Say the average name is 8 chars, then you are looking at a string table size of ~256MB (property name + method name), and then you havent even started coding yet. Just a thought.
这篇关于任何限制的属性数量上的.NET类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!