✅ Any modern approach to getting the calling class typename aside from using the stack frame?
10 years ago I used to use the stack frame to go backwards and get what class is calling my current method. I know there's attributes as well, but they are more physical file based. Is there a modern approach in current .NET to getting this information at runtime? Such as for a logger method that's trying to find out what called it?
S
Sossenbinder•511d ago
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/attributes/caller-information
These are what you are looking for I think
CallerMemberName mostly
A
Accord•509d ago
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
51KMembers
View on DiscordWant results from more Discord servers?
More Posts✅ How can I hide buttons inside a tablelayout?When i make the visible false, they still show, and if i make the visible false on both the tablelay❔ How to reverse engineer your simple console app code?Just curious. Is this possible with programs like x64dbg or... ?❔ Ef Core Constructor problemHello its my first big project with ef. I have an class with 3 attributes and one constructor that i❔ many to many database cant update the 3rd tablecant update the 3rd table who had the cust id and drink id✅ rest requests helphello i am trying to send to os command injections with RestSharp to dvwa for pentestering can someo❔ Source generator, generating type script definitions at compile timeI would like to make a automatic type script definition from code, i consider to use source generato❔ Making an async method without anything to async insidelet's say i have following scenario:
```csharp
void Foo()
{
for(int i = 0 ; i < 10000000 ;i++){} /❔ Reading file from the folder where .csproj isHow can i read files from folder where .csproj is? just like webapps allow to do, they do not copy f✅ Interoperability between incompatible typesHi!
I'm trying to pass a class back-and-forth from C# to CPP.
This class contains some members that ❔ Set item to null inside a listHey! I am trying to remove some items from a JSON object (created like `var model = new ObjectModel{