struct in a different assembly used without initialization #5230
Replies: 4 comments 3 replies
-
The reason why you're getting that error is because you're declaring the local int x;
string s = x.ToString(); On the other hand, if you'd declared your You can see more information on this here: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/cs0165 |
Beta Was this translation helpful? Give feedback.
-
@spydacarnage The question isn't why error CS0165 is generated; the question is why CS0165 isn't generated when |
Beta Was this translation helpful? Give feedback.
-
It doesn't make a difference for me - I get the same error. Hence why I wondered if, in using it from the separate assembly, the code also changed slightly... |
Beta Was this translation helpful? Give feedback.
-
I can reproduce this using .net 5.0 with Visual Studio 16.11.2. When the struct is defined in another assembly I get a warning |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The following C# program doesn't compile
The compiler complains:
error CS0165: Use of unassigned local variable 'ws'
The compiler is Microsoft (R) Visual C# Compiler version 3.10.0-4.21329.37 and the version of .NET Framework is 4.7.2
But, the same program compiles successfully when the
MetaWorkspace
struct definition is moved into a different assembly (DLL) and is included as a reference. How is this so? If this is not a compiler error, am I still dealing with a fully definedMetaWorkspace
object or have I tread into the undefined zone?Beta Was this translation helpful? Give feedback.
All reactions