Public Const Vs Public Property

  • Thread starter Thread starter Karthik
  • Start date Start date
K

Karthik

Dear All,
I have one doubt Regarding Memory ,

I am working on VB .net 2005,

I run the project which has nearly 100 Const variables.

I feel that make all the those const into public shared Propery!

So that i can get the value wherever i want!

Is the above idea reduce the Memory?

Is there any other Idea?

All the words that you send to me is highly appreciated

Thanks in advance



Regards
Karthik.C
 
So that i can get the value wherever i want!
Well, a const can be public too.
Is there any other Idea?
a const and a public static (shared) property work differently; const
values are read at compile-time, where-as properties are read at
runtime. What this means is that if I declare a value in assembly A,
and consume it from B... then I change the value:
* with a static (shared) property, you rebuild and deploy A; as long
as B loads the assembly it should pick up the new value
* with "const", you need to rebuild B for the change to take affect

Marc
 
Marc Gravell said:
Well, a const can be public too.

a const and a public static (shared) property work differently; const
values are read at compile-time, where-as properties are read at runtime.
What this means is that if I declare a value in assembly A, and consume it
from B... then I change the value:
* with a static (shared) property, you rebuild and deploy A; as long as B
loads the assembly it should pick up the new value
* with "const", you need to rebuild B for the change to take affect

Marc

This difference has an impact with databinding to grids and tables.
Constants, because they are read at compile time, cannot be databound
because the databinding actually occurs at runtime. Properties can be
databound because they are computed at runtime.

Mike.
 
Constants, because they are read at compile time, cannot be
databound because the databinding actually occurs at runtime.
Properties can be databound because they are computed at runtime.
True, but the OP stated "shared" property, which I interpret as
meaning static - you can't really data-bind to static properties
without cheating...
Granted, you could have an instance property (getter) that returns the
value of a static field, but it would be a bit hacky...

Marc
 
Back
Top