Christof,
Accessing n will be faster, because when you compile an assembly with a
reference to the assembly containing that constant, that value is
substituted into the code. With readonly fields, you have to actually do a
lookup.
I hope you aren't trying to do this in the hopes of optimizing your
code. It sounds premature, unless you have some performance numbers to back
it up otherwise.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
(E-Mail Removed)
"Christof Nordiek" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi all,
>
> Can there be a performance difference, if i use readonly fields instead of
> constants?
>
> e.g.:
> const int n = 100;
> vs.
> static readonly int = 100;
>
> or
> const string s = "text";
> vs.
> static readonly string s = "text";
>
> Christof
>