Hi,

On 06.04.2011 15:48, Jeffrey Stedfast wrote:
>> static readonly int INSERTIONSORT_THRESHOLD = 7;
>>
>> Why not to used const int ?
>
> I never learned when to use const vs static/readonly in C# :-(

Consts will be expanded inline by the compiler.

pros: fast
cons: versioning trouble when the const is public and it is
consumed by another assembly.

Fields marked with the "readonly" modifier are not inlined
because they are still normal fields.

pros: no versioning issues.
cons: slow.

Robert

_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list

Reply via email to