Why C# local variables must be initialized?

前端 未结 8 594
春和景丽
春和景丽 2020-12-03 22:28

I am reading MCTS Self Paced Training Kit (70-536) Edition 2 and in the 1st chapter we have the following.

How to Declare a Value Type Variable To

8条回答
  •  一个人的身影
    2020-12-03 23:22

    Do make it Role of THUMB in C# and VB.net that before calling any variable, do initilize it first. like

    int myInt; // Simple Declaration and have no value in it 
    myInt= 32; // Now you can use it as there is some value in it..
    

提交回复
热议问题