C
C#2w ago
cheeze2000

Compiler warnings about unused variables

I have a simple program
var a = 40;
var b = a;
var c = 20;

Console.WriteLine(a);
var a = 40;
var b = a;
var c = 20;

Console.WriteLine(a);
On my vscode, only c is underlined with this error: The variable 'c' is assigned but its value is never used Why is b not underlined? I mean it's dimmed but why isn't this a compiler warning as well?
No description
6 Replies
Nasdack
Nasdack2w ago
The warning is issued if and only if the assigned value is a compile-time constant.
cheeze2000
cheeze2000OP2w ago
i see thanks. do you know if there's any setting i can enable that detects b being unused
Nasdack
Nasdack2w ago
b is already inspected and code analysis does tell that it is not being used
cheeze2000
cheeze2000OP2w ago
what i mean is maybe it shows up as a compile-time warning
Nasdack
Nasdack2w ago
You can configure the severity of this inspection It is not a compiler warning, and you can't force it to be one You can however configure IntelliSense or ReSharper to change its severity
cheeze2000
cheeze2000OP2w ago
ok i'll look into it, thanks
Want results from more Discord servers?
Add your server