473,382 Members | 1,733 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,382 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 1384
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.