473,320 Members | 1,829 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,320 software developers and data experts.

Intellisense at runtime

How can you see an object's members at run-time programmatically. I want to
write code that looks like :
MyObject myObject;
foreach ( object member in myObject)
{
DoSomeThingWith(member);
}

Thanks,
Hananiel
Nov 15 '05 #1
3 1809
Could you be a little clearer about what you want exactly?
"Hananiel" <Ha******@junkmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
How can you see an object's members at run-time programmatically. I want to write code that looks like :
MyObject myObject;
foreach ( object member in myObject)
{
DoSomeThingWith(member);
}

Thanks,
Hananiel

Nov 15 '05 #2
You would use reflection to do this.

Something like:

using System.Reflection;

Type t = typeof(MyObject);
MemberInfo[] members = t.GetMembers();
foreach(MemberInfo mi in members){
//Do what you want here
}

GetMembers gets all the members of the given type. There
is also GetProperties, GetMethods, GetInterfaces, etc.

Also, you can pick out a member by name instead of
retrieving an array: t.GetMethod("CookSalsburySteak");

HTH,
Charlie
-----Original Message-----
How can you see an object's members at run-time programmatically. I want towrite code that looks like :
MyObject myObject;
foreach ( object member in myObject)
{
DoSomeThingWith(member);
}

Thanks,
Hananiel
.

Nov 15 '05 #3
Thank you. Just what i needed.
-Hananiel
"Charlie Williams" <cw***********@hotmail.spamfree.com> wrote in message
news:f4****************************@phx.gbl...
You would use reflection to do this.

Something like:

using System.Reflection;

Type t = typeof(MyObject);
MemberInfo[] members = t.GetMembers();
foreach(MemberInfo mi in members){
//Do what you want here
}

GetMembers gets all the members of the given type. There
is also GetProperties, GetMethods, GetInterfaces, etc.

Also, you can pick out a member by name instead of
retrieving an array: t.GetMethod("CookSalsburySteak");

HTH,
Charlie
-----Original Message-----
How can you see an object's members at run-time

programmatically. I want to
write code that looks like :
MyObject myObject;
foreach ( object member in myObject)
{
DoSomeThingWith(member);
}

Thanks,
Hananiel
.

Nov 15 '05 #4

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

Similar topics

8
by: andrew.queisser | last post by:
Yesterday I typed in some C++ code that called a function with two ints. Intellisense (auto-complete) helpfully told me that the first formal parameter was called "frontLight" and the second...
6
by: Stefan Kronberg | last post by:
I'm working on a solution containing about 20 projects. Some of the projects contain class definitions that are used in other of the projects. Most of the time intellisense is working ok, i.e. if I...
1
by: Christopher W. Douglas | last post by:
I'm working in VB.Net, using Visual Studio 2003. I have a project, let's call it Foo, that contains common methods, forms, and objects I use in other projects. It compiles as Foo.dll, which I...
9
by: Ulf Lindback | last post by:
Hi! We have an application surveillance product with a number of API's for different languages; one of them is a C API. Now I wonder how we can supply intellisense to our Visual Studio.Net...
0
by: Sec_Newbie | last post by:
Why do I never see any intellisense from VS.NET (2003), when in AssemblyInfo.cs file? The below is my file with all the using statements that should at least present intellisense for...
2
by: Ron | last post by:
Hello, Is there intellisense for vb.net dll's? Here is a simple dll I wrote which I invoke in MS Access. Note: I set the build property to include registration for Com Interop = True:...
2
by: Natan Vivo | last post by:
Can anyone tell me what exactly what makes intellisense works for custom controls in aspx pages in VS 2005? I just installed Atlas in my office computer, created a new atlas project and it...
5
by: wal | last post by:
Hello, I'm using __declspec(property) to access get/set methods as properties (like in C# and VB.NET). Now, the problem is that both the property name and the get/set methods show in the...
11
by: kimiraikkonen | last post by:
Hi there, I needed to use MouseOver event on Webbrowser which is NOT provided by webbrowser control natively(what a disappointment), so i decided to go with another route to simulate this like: ...
3
by: Travis | last post by:
Hi, I was a user of Visual C# for a while and have gotten used to the Intellisense for that program. I went to try Visual Basic, and the intellisense is so much different. I'll try to make an...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
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
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.