why in c# we need to initialize primitive type variable? -


this question has answer here:

why in c# need initialize primitive type variable --

static void main(string[] args) {    int a;    console.writeline(a); } 

throws compile time error ...

in order prevent potential coding mistakes, c# not allow use local variable until compiler can prove has been initialized.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -