Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using the following line of code to get the method name.

stackTrace = new StackTrace().GetFrame(0).GetMethod().ReflectedType.Name;


The method is a test named
public async Task IpToCountryMapping_ValidIPs_ShouldSucceedMapping


The
stackTrace 
value returned is

"<IpToCountryMapping_ValidIPs_ShouldSucceedMapping>d__9"


Why I am getting result enclosed withing the <> and have d_9 at the end?

What I have tried:

Nothing apart from some search
Posted
Updated 20-Nov-19 21:25pm
Comments
RickZeeland 21-Nov-19 3:25am    
And what happens if you use normal methods (not a test) ?

1 solution

The "d" indicates it's an iterator, the "9" is just a sequence number and provides uniqueness to the return value. The bit in the "<" and ">" is the method name that the task is coming from.

This may help (or more likely confuse) you: c# - Where to learn about VS debugger 'magic names' - Stack Overflow[^]
 
Share this answer
 
Comments
jimmson 21-Nov-19 3:31am    
5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900