attribute
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Lab {
public void doSomething()
{
TraceMessage("ha");
}
public void TraceMessage(
[CallerMemberName] string callerName = null,
[CallerFilePath] string callerFilePath = null,
[CallerLineNumber] int callerLine = -1)
{
Console.WriteLine("Caller Name: {0}", callerName);
Console.WriteLine("Caller FilePath: {0}", callerFilePath);
Console.WriteLine("Caller Line number: {0}", callerLine);
}
}
public class Program
{
static void Main(string[] args)
{
Lab lab = new Lab();
lab.doSomething();
}
}
}
一般用来写错误信息