Getting at a value

Hi
I want to get at a value in an instantiation of a class.

Im using Visual Studio 2005

When in debug mode I hover over the variable oControl and it says

oControl {DefaultControlsPlugin.Contols.ElementLabelControl}

then I hit the + beside that and it shows me certain values

_oGuid
_oOwner
etc

However the value I want is under
[DefaultControlsPlugin.Controls.ElementLabelControl]

And I click on + again and its in there as _sText

When I go to the HTML visualizer for this value it says

((DefaultControlsPlugin.Controls.ElementLabelControl)(oControl))._sText

But how do I print this out in my code?

I can do

myvalue = oControl.ToString();

but that sets myvalue to be
DefaultControlsPlugin.Controls.ElementLabelControl

Thanks
Paul

paulwhelanAsked:
Who is Participating?
 
Carl TawnSystems and Integration DeveloperCommented:
You probably can't access it directly because, judging by the name, it is either private or protected. You could probably get to it using reflection, but that is a bit more complex.

Have you tried accessing the value using something like:

    string s = ((DefaultControlsPlugin.Controls.ElementLabelControl)(oControl))._sText
0
 
paulwhelanAuthor Commented:
nice one - that worked!

Any ideas why? =)

Cheers
Paul
0
 
Carl TawnSystems and Integration DeveloperCommented:
Well.... _sText must be public. So by using:

    ((DefaultControlsPlugin.Controls.ElementLabelControl)(oControl))

You are casting oControl to the correct type, before trying to access the _sText member
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.