[Removed invalid group microsoft.public.dotnet.csharp.general]
Marty <xmarty99@hotmail.com> wrote:[color=blue]
> Thank you everybody for your help,
>
> The singleton pattern seem very interesting, I'll read on that.
>
> Concerning the global constants, let's say that I place the constants
> within a class, then access one of them by "myClassObj.Constant1".
>
> Does the compiler will place the constant value inline everywhere the
> "myClassObj.Constant1" is called?[/color]
It does if it's declared as const; it doesn't if it's declared as
public static readonly.
[color=blue]
> This is because I need full speed at runtime, I don't want it to make
> overhead calling the constant like if it was a variable.[/color]
The JIT should be able to compile the value in if it's a readonly value
type or string (the latter being immutable) although I haven't checked
to make sure that it does.
I would be very wary of worrying about this kind of thing though - the
performance hit for that referencing a static variable in another class
is very, very, very unlikely to be a bottleneck in your code.
--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too