Reputation: 2626
I would like to know the differences between these two ways of declaring variables.
Type 1
private string procedure_add = "";
private string procedure_update = "";
private string procedure_delete = "";
Type 2
private string procedure_add = "", procedure_update = "", procedure_delete = "";
Does this give the same effect?. Is the memory consumption the same?
Upvotes: 1
Views: 516
Reputation: 15861
There is no any difference. it's all about the accessibility. the way how the code looks. suppose if you have 10000+ line of code, while editing you may get stumped by identifying the "," in declaration .
this method which i prefer to use.
private string yourVar = String.Empty;
Upvotes: 4
Reputation: 50672
In addition to the overall "They are the same, but differ in readability" I would like to add 3 remarks:
Dim x , y as Integer
would result in y being an Integer and x a Variantint *ip, i;
would result in ip being a pointer to an int and i to be an int.int *ip, i;
will result in ip being a pointer to int and i ALSO being a pointer to int.Upvotes: 0
Reputation: 163
I think no different, from my understanding second type is to minimize the line of code.
Upvotes: 0
Reputation: 62246
There is no any difference. Just coding style.
EDIT
As @Aphelion mantioned in first case you can modify accessibility.
From the code generation point of view the both version produce exactly the same IL
MyClass..ctor:
IL_0000: ldarg.0
IL_0001: ldstr ""
IL_0006: stfld UserQuery+MyClass.procedure_add
IL_000B: ldarg.0
IL_000C: ldstr ""
IL_0011: stfld UserQuery+MyClass.procedure_update
IL_0016: ldarg.0
IL_0017: ldstr ""
IL_001C: stfld UserQuery+MyClass.procedure_delete
IL_0021: ldarg.0
IL_0022: call System.Object..ctor
IL_0027: ret
Upvotes: 1