Можно ли использовать регион в качестве переменной?C#

Место общения программистов C#
Гость
Можно ли использовать регион в качестве переменной?

Сообщение Гость »


I'm performing a cleanup of the database in my code. It looks as follows:

#region Orders and SubOrders try { ... // this code tries to remove the Orders and the SubOrders } catch (Exception ex) { _logger.Error($"An exception occurred while cleaning Orders and SubOrders. Error message=[{ex.Message}]"); } #region Customers try { ... // this code tries to remove the Customers } catch (Exception ex) { _logger.Error($"An exception occurred while cleaning Customers. Error message=[{ex.Message}]"); } Is it possible to replace the _logger line by something like:

_logger.Error($"An exception occurred while cleaning [{#currentregion}]. Error message=[{ex.Message}]"); Thanks in advance


Источник: https://stackoverflow.com/questions/781 ... a-variable

Вернуться в «C#»