[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Getting at a value

Posted on 2006-03-29
3
Medium Priority
?
188 Views
Last Modified: 2010-04-16
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

0
Comment
Question by:paulwhelan
  • 2
3 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 400 total points
ID: 16322904
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
 

Author Comment

by:paulwhelan
ID: 16323100
nice one - that worked!

Any ideas why? =)

Cheers
Paul
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 16323172
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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

829 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