List of functions in a class

M

Marco Balk

I want to create my own ToString() function, which outputs a summary
of a class.
How can I retrieve a list of functions in a class?

I want to try to get the following output (this will be a nice HTML
list):

Class foo
- functions:
--- static function static_foo()
--- public function public_foo()
--- private function private_foo()
- variables
--- public int X
--- public string Y
--- protected bool Z
- properties
--- public string Name
--- public int Age


Code example:

foo objFoo = new foo();
Response.Write(objFoo.ToString());


Thanks in advance!!!
 
J

Jon Skeet [C# MVP]

I want to create my own ToString() function, which outputs a summary
of a class.
How can I retrieve a list of functions in a class?

I want to try to get the following output (this will be a nice HTML
list):

Class foo
- functions:
--- static function static_foo()
--- public function public_foo()
--- private function private_foo()
- variables
--- public int X
--- public string Y
--- protected bool Z
- properties
--- public string Name
--- public int Age

Code example:

foo objFoo = new foo();
Response.Write(objFoo.ToString());

Thanks in advance!!!

Well, at that point you're really writing out information about the
*type* rather than about the object itself (unless you include the
values of the properties etc).

There are various methods on Type which return the fields, methods,
properties etc. You'll need to think about whether you want to show
inherited members as well.

Jon
 
M

Marco Balk

Well, at that point you're really writing out information about the
*type* rather than about the object itself (unless you include the
values of the properties etc).

There are various methods on Type which return the fields, methods,
properties etc. You'll need to think about whether you want to show
inherited members as well.

Jon

Thanks Jon.

This is just what I need.
I guess there's no way to display private or protected Members?
 
J

Jon Skeet [C# MVP]

This is just what I need.
I guess there's no way to display private or protected Members?

Yes, you just need to specify BindingFlags.NonPublic.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top