I am trying to write a custom attribute which will log start time of a method.
Here it is my code :
public class Program
{
public static void Main(string[] args)
{
try
{
CompareBusinessUnits();
}
catch (Exception ex)
{
throw;
}
}
[RecordTime]
private static void CompareBusinessUnits()
{
// to do something
}
}
public class RecordTimeAttribute : Attribute
{
public void PrintStartTime()
{
Console.WriteLine("Start Time " + DateTime.Now);
}
}
But console window does not show start time. I want to print the time when the method starts.