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

MACROS for current function name?

C++ has some nice macros for obtaining the current function name, current
source file, and current line number (__FUNCTION__, __FILE__, __LINE__).
Does C# have any comparable MACROS?

Nov 1 '06 #1
1 2916
C# doesn't have macros. But you still can get the info you are looking for
via standard API:

// __FUNCTION__
System.Diagnostics.StackFrame f = new System.Diagnostics.StackFrame (true);
MessageBox.Show (f.GetMethod().Name);

// __LINE__
System.Diagnostics.StackFrame f = new System.Diagnostics.StackFrame (true);
MessageBox.Show (f.GetFileLineNumber().ToString());
// __FILE__
System.Diagnostics.StackFrame f = new System.Diagnostics.StackFrame (true);
MessageBox.Show (f.GetFileName());
"Scott McFadden" <no**************@criticaltech.comwrote in message
news:ex**************@TK2MSFTNGP03.phx.gbl...
C++ has some nice macros for obtaining the current function name, current
source file, and current line number (__FUNCTION__, __FILE__, __LINE__).
Does C# have any comparable MACROS?

Nov 1 '06 #2

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

Similar topics

21
by: Chris Reedy | last post by:
For everyone - Apologies for the length of this message. If you don't want to look at the long example, you can skip to the end of the message. And for the Python gurus among you, if you can...
16
by: mike420 | last post by:
Tayss wrote: > > app = wxPySimpleApp() > frame = MainWindow(None, -1, "A window") > frame.Show(True) > app.MainLoop() > Why do you need a macro for that? Why don't you just write
12
by: David Powell | last post by:
Because my work area won't have an Access programmer next year, I've been asked to rebuild their coded application as a set of modular tools. The idea is that a non-programmer will be able to...
0
by: jpodesta | last post by:
Hello- I am fairly new to MS Access and would like to use some macros in .xls in an Access Module. I have tried to do this on my own but failed to make it work. I have included the xls macros...
37
by: hasadh | last post by:
Hello, probably this may be a simple qn to u all but I need an answer plz. In my software i used macros like OK,TRUE,FALSE,FAILURE . A friend who included this code as a library into his module...
5
by: Andreas Micheler | last post by:
Hi, I have several long complex C macros in the math module of aUCBLogo like #define _XFUNC_primitive(NAME)\ NodeP _##NAME(PairPP arg)\ { ((ObjectP)(arg))->var()->NAME( arg );\ return...
13
by: Anthony de Almeida Lopes | last post by:
Hello, I am wondering why it is not possible to have a function-like macro like the following: #define __nothread(name) do { \ #ifdef _PTHREAD_H ...
47
by: Emil | last post by:
Is there any hope that new versions of PHP will support macros similar to C or C++? I've searched manual and didn't find anything except define directive, but it can be used to define constant...
3
by: Floobar | last post by:
Macros sure can be fun -- and profitable. This actually worked -- it might work for any of you guys too. The trick is to make your code look sensible, but be actually very hard to modify without...
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: 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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...

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.