Answer the question
In order to leave comments, you need to log in
Perhaps a funny question, but - is there an analogue of "C# extension methods" in Delphi?
I don't even know what's better? quote? or provide a link? there was a question about debugging in C #, there I just illustrated my favorite tricks .. I'll try to make a big quote:
you can implement your simplest logger as an extension (in a utility static class), example
internal static void log(this string txt) => tbLog.AppendText(txt + Environment.NewLine);
then very convenient to use anywhere
$"что то прошло не так, параметры первый {} и второй {}".log();
... and more convenient compiler options, for constructs that are clearly not needed in production
#if DEBUG var sw = new Stopwatch(); sw.Start(); #endif /// что то делаем #if DEBUG sw.Stop(); var ts = sw.Elapsed; $"total time:".log(); $"\t{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00}.{ts.Milliseconds:000}".log(); #endif
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question