Getting at a value

Posted on 2006-03-29
Last Modified: 2010-04-16
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


Question by:paulwhelan
    LVL 52

    Accepted Solution

    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

    Author Comment

    nice one - that worked!

    Any ideas why? =)

    LVL 52

    Expert Comment

    by:Carl Tawn
    Well.... _sText must be public. So by using:


    You are casting oControl to the correct type, before trying to access the _sText member

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Article by: Ivo
    C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
    Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now