Suppose I am working on Welcome.cs file. In the constructor I want to print "Welcome". However, If I put the same code in HelloWorld.cs, it should print HellowWorld. How do I do that?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
If you want to get the class name, you can use Reflection technique.
eg:
you can get the name of the class from
classType.Name
How to print
[current file name - method name - line number] ?
Test:
Output:
if I've understood correctly, try
this.GetType().Name
You can try
Try this to get the file name:
To get the current line: