Re: Convert String to variable contained in string
- From: "Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 14 Apr 2005 14:31:59 -0400
Gregory,
In order to do something like this, you would have to create a wrapper
for the value which is a reference type, and then pass that around, instead
of the int itself. This way, if you change the wrapper, you are changing
instances, and when the wrapper is assingned to the variable, they all point
to the same wrapped integer.
--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx
"gmccallum" <gmccallum@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:89E2D8DD-8233-4E3F-8B2E-A02246A4D922@xxxxxxxxxxxxxxxx
> The reason I am doing this approach to a problem is because I
> don't know how to create a reference to a value type.
>
> For example in C++:
> int x = 10;
> int *y = &x;
>
> When I update x, I want to be able to see the change in y.
>
> In C# because int is a value type when I say:
> int x = 10;
> int y = x;
> it creates a copy of x and puts it in y.
>
> Is there a way to do this without having to use unsafe construct?
>
> It still would be useful to be able to get the value of a variable in a
> string like
>
> string varName = "MyClass.intvalue";
> would like to get value of MyClass.intvalue.
>
> So an answer to both issues would be really appreciated.
>
> -Gregory McCallum
>
.
- References:
- Convert String to variable contained in string
- From: gmccallum
- RE: Convert String to variable contained in string
- From: gmccallum
- Convert String to variable contained in string
- Prev by Date: Re: fields or properties
- Next by Date: Re: System.NullReferenceException - Object reference not set to an instance of an object
- Previous by thread: RE: Convert String to variable contained in string
- Next by thread: Re: Convert String to variable contained in string
- Index(es):
Relevant Pages
|