473,327 Members | 2,007 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Public Const Vs Public Property

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

----------------------------------------------------------
Winners do not do different things. They do things differently.
Sep 5 '07 #1
3 3827
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
Sep 5 '07 #2

"Marc Gravell" <ma**********@gmail.comwrote in message
news:e$****************@TK2MSFTNGP02.phx.gbl...
>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
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.

Sep 8 '07 #3
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
Sep 11 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Zap | last post by:
Widespread opinion is that public data members are evil, because if you have to change the way the data is stored in your class you have to break the code accessing it, etc. After reading this...
1
by: Erik Tamminga | last post by:
Hi, I'm totally bluffed: how can a 'public const string name = "myname";' ever evaluate to null? I have the following class: public class MIB2 { public const string org = "1.3";
18
by: Janaka | last post by:
I'm having a discussion with my colleagues here on good programming standards. One thing we haven't agreed on is the use of properties in classes vs using member variables. Now everyone knows...
3
by: Morten | last post by:
Hi! I'm trying to manage public folders using C#. I have found some code that allows me to mail enable a folder: foreach( System.Management.ManagementObject instmailbox in queryCollection ) {...
4
by: Nick Dreyer | last post by:
Is it possible to see public class variables of a COM addin in Excel 97 VBA? I have successfully created the (Visual Basic 2003 .NET) COM and referenced it in an Excel 97 VBA project. The VBA...
9
by: Stefan De Schepper | last post by:
Should I use: Private m_Name As String Public Property Name() As String Get Return m_Name End Get Set(ByVal Value As String) m_Name = Value
8
by: Gregory | last post by:
I have a question about using STL containers in C++ class public interface. Lets say that I want to return some container from class method or accept class method parameter as some container. For...
1
by: =?Utf-8?B?d3BjbWFtZQ==?= | last post by:
I got the following code public ref class A { value struct PrivateType sealed { Int32 id; }; public: ref struct B abstract sealed { static const PrivateType x = {1}; static const PrivateType...
2
by: fgh.vbn.rty | last post by:
Hi, I'm not sure if i'm asking the question correctly but anyway here it is. Say I have 3 classes - class A, class B, class R. 1) A and B are the building blocks and R is like a repository...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.