473,385 Members | 2,069 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,385 software developers and data experts.

get the name of a property

Is it possible to get the name of a property?

Something Like having a method that I could pass as argument the property of class and get back the propertyName

string name=GetPropertyName(class1.Property)
Nov 22 '05 #1
2 1385
Not sure how you can do that specifically but I would start my search by
looking into Reflection. With Reflection you can interate through a class
and generate a list (strings) of all the methods, properties, etc.

- Jason

"A.Bekiaris" <to*****@otenet.gr> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Is it possible to get the name of a property?

Something Like having a method that I could pass as argument the property
of class and get back the propertyName

string name=GetPropertyName(class1.Property)

Nov 22 '05 #2
Hi Bekiaris,

As jason pointed out, you can do it using reflection.

Type <somename> =
Assembly.GetExecutingAssembly().GetType("<yourname space.classname>");

someFieldInfo <handyfieldinfoName> =
<somename>.GetField("<staticvariablename>", BindingFlags.Static |
BindingFlags.SetProperty);

Gives you the set property of the class.

Try to loop thro' other functionalites under <somename> also.

Regards,

venkat.Murthy

"Jason" <Ja*******@hotmail.com> wrote in message
news:eV**************@TK2MSFTNGP14.phx.gbl...
Not sure how you can do that specifically but I would start my search by
looking into Reflection. With Reflection you can interate through a class
and generate a list (strings) of all the methods, properties, etc.

- Jason

"A.Bekiaris" <to*****@otenet.gr> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Is it possible to get the name of a property?

Something Like having a method that I could pass as argument the property
of class and get back the propertyName

string name=GetPropertyName(class1.Property)


Nov 22 '05 #3

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

Similar topics

14
by: Altman | last post by:
Ok I have a control that is inherited from another class. In the child I put msgbox(me.name) in the load event. What always pops up is the name of the parent class and not the name of the...
7
by: JohnR | last post by:
I have a user defined class that contains about 20 private variables with their associated properties and get-sets. I have named the properties with very user readable names. I would like to...
20
by: weston | last post by:
I've got a piece of code where, for all the world, it looks like this fails in IE 6: hometab = document.getElementById('hometab'); but this succeeds: hometabemt =...
11
by: Alexander Walker | last post by:
Hello I would like to write a method that allows me to pass a reference to an instance of a class, the name of a property of that class and a value to set that property to, the method would then...
12
by: Eric | last post by:
I have a custom component that can be dragged from the ToolBox onto a Windows Form (which means I can't modify it's constructor to add a name parameter). VS assigns it an instance name, but the...
3
by: TomislaW | last post by:
I am sending word document with e-mail from asp.net 2.0 application. I read doc file like this:FileStream fs = System.IO.File.Open(docPath,FileMode.Open,FileAccess.Read,FileShare.Read); Then...
7
by: Nemisis | last post by:
Hi everyone, Can anyone tell me if it is possible to pass in a property of an object into a sub, and within that sub, find out the name of the item that was passed along with the property name??...
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...
10
by: Rob | last post by:
I am reading a book that says that the "name" property can be altered only at design time and cannot be modified at runtime. Please explain this given the code below... If you click Button3......
3
by: Peter Gast | last post by:
Hi, I need as a parameter for a control the names of my properties as a string. How can I get the name of the property as a string during runtime Example: Private _MyVar As Double Public...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.