-3

I'm new in using get, set in C#. By declaring as follow it will throw an exception whenever I'm initializing the WPF page. I couldn't figure out what is wrong. Appreciate your help

I'm trying to declare the following function as below:

public DebugProductionWindow()
    {
        //Single window testing
        InitializeComponent();
        GUIParameters localGUIParameters = null;   
        localGUIParameters.mpsManualControl = new MPSManualControl();
     }




public class GUIParameters
{
    public Windows.DebugProduction.MPSManualControl mpsManualControl { get; set; }
}

1 Answers1

3

Sharing the actual exception you get will greatly help towards finding a solution. I'm guessing though that these lines cause your issue:

GUIParameters localGUIParameters = null;   
localGUIParameters.mpsManualControl = new MPSManualControl();

This will throw a NullReferenceException. Don't set it to null, instantiate a new GUIParameters() instead.

CodeCaster
  • 147,647
  • 23
  • 218
  • 272