473,387 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

convert name of object into object itself

i have a class with a great number of private properties ...

the class contains various functions that accept as a parameter the name of
one of the private properties. the functions perform various operations on
the current value of the property ...

in the function's internal code, i'd like to obtain the value of the
relevant property without doing a lengthy

Select pParameterName
Case "MyParam1"
ParameterValue = mMyParam1
etc.

does .NET provide a mechanism to convert a string giving the name of an
object into the object itself?
Nov 20 '05 #1
6 1076
Hi John,

Strange patterns occur sometimes. The same question but from a different
viewpoint appears only minutes apart from yours. So the same answer for both!
;-)

Have a look and see if CallByName is of any use to you.

If that's not suitable, the next to look at is the Type class. (use
GetType on the object which owns the method/member that you are interested.
This has GetField/GetFields and GetMember/s which may do the job.

Regards,
Fergus
Nov 20 '05 #2
* "Fergus Cooney" <fi*****@post.com> scripsit:
Have a look and see if CallByName is of any use to you.


'CallByName' won't work on private members.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
How does one programmatically determine the type of an object, such as a
control ... ?

If MyControl.GetType() = HTMLControls.HTMLSelect Then

doesn't work ...

nor does

If MyControl.GetType() Is HTMLControls.HTMLSelect Then


"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:ej*************@TK2MSFTNGP11.phx.gbl...
* "Fergus Cooney" <fi*****@post.com> scripsit:
Have a look and see if CallByName is of any use to you.


'CallByName' won't work on private members.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

Nov 20 '05 #4
"John A Grandy" <johnagrandy-at-yahoo.com> schrieb
How does one programmatically determine the type of an object, such
as a control ... ?

If MyControl.GetType() = HTMLControls.HTMLSelect Then

doesn't work ...

nor does

If MyControl.GetType() Is HTMLControls.HTMLSelect Then


If TypeOf MyControl Is HTMLControls.HTMLSelect

--
Armin

http://learn.to/quote

Nov 20 '05 #5
Hi John,

And the other way is long-winded:
If MyControl.GetType() Is GetType (HTMLControls.HTMLSelect) Then

So you were on the right lines but they were crossed. ;-)

With Armin's version I usually use TypeOf (MyControl) as it looks more
like a function.

Regards,
Fergus
Nov 20 '05 #6
* "John A Grandy" <johnagrandy-at-yahoo.com> scripsit:
How does one programmatically determine the type of an object, such as a
control ... ?

If MyControl.GetType() = HTMLControls.HTMLSelect Then


\\\
If TypeOf MyControl Is HTMLControls.HTMLSelect Then
...
End If
///

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: manish | last post by:
I have created a function, it gives more readability compared to the print_r function. As of print_r, it works both for array or single variable. I just want to add in it, the opton to view the...
4
by: Eric Lilja | last post by:
Hello, I've made a templated class Option (a child of the abstract base class OptionBase) that stores an option name (in the form someoption=) and the value belonging to that option. The value is...
1
by: Bell, Kevin | last post by:
I'm pulling a range of cells from Excel into a list and the data in Excel is a number or possibly some text like an asterisk. Each member of the list is a com object (I think) and I'm converting...
4
by: Tamir Khason | last post by:
How can I convert (elegant way) Collection to Array without looping and new instances. E.G: I want to add elements of one menu to other, so secondMenu.MenuItems.AddRange(firstMenu.MenuItems);...
9
by: Andy Sutorius | last post by:
Hi, I am receiving the error when compiling the project, "cannot implicitly convert type object to string". The error points to this line of code and underlines the dtrRecipient:...
5
by: manmit.walia | last post by:
Hello All, I am stuck on a conversion problem. I am trying to convert my application which is written in VB.NET to C# because the project I am working on currently is being written in C#. I tried...
1
by: Jorge | last post by:
I want to convert this xml to pdf using cocoon <?xml version="1.0" encoding="ISO-8859-1" ?> <document> <header> <title>Pagina</title> </header> <body> <h1>Link dei siti pił visitati da...
12
by: -Lost | last post by:
What in the world is functionName.name good for? That is: function functionName() { return functionName.name; } I mean, I already had to write out the function's name so it seems that it is...
5
by: sonu | last post by:
hey good morning ...... how to convert a video file in .flv format in php for linux hosting......is there any package whis provide this facility . Can i use ffmpeg for linux hosting...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.