|
| passing property values from class to class |
|
|
|
|
| Messages |
|
Related Types |
This message was discovered on microsoft.public.dotnet.languages.vc.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
| Glenn Kunsman via .NET 247 (VIP) |
(Type your message here)
-------------------------------- From: Glenn Kunsman
I hope this is the right forum...
I need to access a public class without using the new keyword and losing the current values.
I have created a public class
public class classClientData { private string _clientId;
public string clientId { get { return _clientId; } set { _clientId = value; } } }
if I instantiate the class...
classClientData clientData = new classClientData(); clientData.clientId = "some value"; MessageBox.Show(clientData.clientId);
this works fine but I want to access the value in anothe class/form without using the new keyword and I cannot figure out a way to do this..
currently I have a struct with all of the config values and I pass the struct to the class constructor and all of the associated values (in the struct). This works fine but it is a little messy and I have to watch out for values changes and stale data...
Any suggestions? Thanks in advance for your time
Glenn
----------------------- Posted by a user from .NET 247 (http://www.dotnet247.com/)
<Id>2oh6+G6I9U6+g94TsjlnOQ==</Id>
|
|
|
| |
|
|
| |
| |
| Lord2702 |
Sat. Aug. 28, 2004 10:30 PM PT
First of all, you are asking VC# problem in VC forum. Anyway, here is the answer for your problem, You can not get the Property value w/o. instantiating (i.e. with new ) your class, although, you still want a property value, them make your field/ variable, static, and make the Get/ Set properties static, and then use your class name to access the property.
Good Luck
"Glenn Kunsman via .NET 247" <Click here to reveal e-mail address> wrote in message news:OFw$Click here to reveal e-mail address... [Original message clipped]
struct). This works fine but it is a little messy and I have to watch out for values changes and stale data... [Original message clipped]
|
|
|
| |
|
| |
|
|
|
|
|
|
|
|
BootFX
Reliable and powerful .NET application framework. |
|
|
|
|
|
|