Getting at a value

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


However the value I want is under

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

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


But how do I print this out in my code?

I can do

myvalue = oControl.ToString();

but that sets myvalue to be


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
paulwhelanAuthor Commented:
nice one - that worked!

Any ideas why? =)

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


You are casting oControl to the correct type, before trying to access the _sText member
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.