C#: "field is not assigned to" warning

Discuss other programming languages besides AutoHotkey
Posts: 186
Joined: 08 Sep 2014, 07:06

C#: "field is not assigned to" warning

07 Sep 2017, 14:45

Hey guys, newbie question here: I've got a class with a property that is an instance of another class. That other class has no parameters in its constructor (and really, no constructor at all) but I'm getting this ridonkulous message saying the property is never assigned too, will always be null, and Kiss My Bits. :P

Here's the code:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

My best guess is that it has something to do with access modifiers ("internal" vs. "public") but that's not the error I'm getting. And to add to the mystery, the error makes no sense whatsoever - at least, not from my (admittedly human) perspective; obviously there's a blatant mistake in the Oz-like world the compiler lives in. Never assigned to? Isn't the NEW on the SAME LINE assigning it??? I must be missing something stupidly simple, because hair-jerkers like this are never half as complicated as they seem.

Return to “Other Programming Languages”

Who is online

Users browsing this forum: No registered users and 3 guests