I often see the following convention in C # code:
some_type val;
val = something;
as
DataTable dt;
dt = some_function_returning_datatable();
or
DataTable dt = new DataTable();
dt = some_function_returning_datatable();
instead
some_type val = something;
DataTable dt = some_function_returning_datatable();
It was originally supposed to be a habit left after you had to declare all the local variables at the top of the area. But I learned how to quickly give up the habits of veteran developers.
(In my third section of code, this will not be memory loss when assigned dtfirst with new, and then from a function)
So, is there a good reason for a single line declaration and subsequent assignment?
source
share