C#

C#

Made by DeepSource

Variable is uninitialized CS-W1022

Bug risk
Major

While some variables such as fields can be initialized and be assigned a default value, it is possible for local variables to not be initialized. This however is not a good practice as it is capable of critically altering your program's path, thereby affecting its logic.

It is therefore recommended that you always initialize variables, ideally where they're being declared.

Bad Practice

// invalid: here `x` is uninitialized
int x, y = 2;

Recommended

int x = 1, y = 2;