473,503 Members | 1,648 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

name of current method

How can I know what method I am currently on.
public void Hello(){
//some code that says, you are in method Hello()
}

the only solution I can come up with is creating an exception and getting
the stack trace and pasing the text, but that aint a pretty solution.

Nov 15 '05 #1
3 3829
I'm not sure what you're after, but why can't you just write it out by hand?

for example:

public void Hello(){
Console.WriteLine("you are in method Hello()");
}
"memememe" <[rem]casolorz[rem]@hot[rem]mail.com> wrote in message
news:se********************@news2.central.cox.net. ..
How can I know what method I am currently on.
public void Hello(){
//some code that says, you are in method Hello()
}

the only solution I can come up with is creating an exception and getting
the stack trace and pasing the text, but that aint a pretty solution.

Nov 15 '05 #2
memememe,
Its easier to just create a new System.Diagnostics.StackFrame object, then
use the GetMethod method to find out where you are.

You may also want to review the System.Diagnostics.StackFrame class...

Hope this helps
Jay

"memememe" <[rem]casolorz[rem]@hot[rem]mail.com> wrote in message
news:se********************@news2.central.cox.net. ..
How can I know what method I am currently on.
public void Hello(){
//some code that says, you are in method Hello()
}

the only solution I can come up with is creating an exception and getting
the stack trace and pasing the text, but that aint a pretty solution.

Nov 15 '05 #3
On Wed, 03 Sep 2003 19:25:12 GMT, "memememe"
<[rem]casolorz[rem]@hot[rem]mail.com> wrote:
How can I know what method I am currently on.
public void Hello(){
//some code that says, you are in method Hello()
Console.WriteLine ("You are in void Hello()");
}


Why would you want to generate that at runtime? It seems to me that
this would be a bigger cost than just litterally stating the
functionName

--
NULL
Nov 15 '05 #4

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

Similar topics

2
1763
by: juchytil | last post by:
Here is a method that calls a static GetInfo() method on the MyObject class. public void MethodName(string param1, int param2) { MyObject.GetInfo(); } Is there any way for the GetInfo()...
11
21888
by: Ken Varn | last post by:
I want to be able to determine my current line, file, and function in my C# application. I know that C++ has the __LINE__, __FUNCTION__, and __FILE___ macros for getting this, but I cannot find a...
15
1969
by: Mark Kamoski | last post by:
Hi Everyone-- Please help. How can one get the name of the current project and the current class? This is the situation. Suppose there is a project called "P1".
2
3941
by: nalbayo | last post by:
what's the difference between HttpContext.Current.User.Identity.Name; and Context.User.Identity.Name; thanks!
7
5558
by: clr | last post by:
I like to stamp trace logs with the name of the executing Class and Method. I can get the Class Name using GetType.Name and I can get a list of every Method in the class using...
4
2052
by: Nikolay Petrov | last post by:
Hi guys, I am implementing a loging system in my app and I need a way to get name of current class and name of the current method, so I can pass them to my loging system. Also I want to asign...
8
8839
by: news.microsoft.com | last post by:
How do I get the class name for a current instance. For example, if I want to know the Class Name for the current form, how do I get this programatically. Thanks
9
2992
by: Alex | last post by:
Get the Name and Phone Number of the Current Windows User in a .NET Application I am writing a simple .NET (C#) application. It needs to "automatic" get the Name (last, first) and phone number...
11
1819
by: Mick Walker | last post by:
How can I find the name of the current function being executed. For example, lets say I have the following function void Blah(int? y){ int z; try { z = y; } catch(Exception ex){
7
2663
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
I have a C# logging assembly with a static constructor and methods that is called from another C# Assembly that is used as a COM interface for a VB6 Application. Ideally I need to build a file...
0
7072
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
7271
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,...
0
7319
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...
0
5570
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4998
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3149
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1498
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
373
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.