Getting rid of precompiler directives in C#
问题 I've been asked to maintain some not-as-legacy-as-I-would-like code, and it is riddled with compiler directives, making it pretty much unreadable and almost as maintainable. Case in point: #if CONDITION_1 protected override void BeforeAdd(LogEntity entity) #else protected override void BeforeAdd(AbstractBusinessEntity entity) #endif { #if CONDITON_1 entity.DateTimeInsert = DateTime.Now; #else ((LogEntity) entity).DateTimeInsert = DateTime.Now; #endif base.BeforeAdd(entity); } using directives