Note that there are some explanatory texts on larger screens.

plurals
  1. POExplanation of how this code works (C#)
    text
    copied!<p>Can anyone explain me the following code:</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; using System.Drawing; namespace web.frmcolor { public class FormEx : Form { /// &lt;summary&gt; /// Set the default color for the designer /// &lt;/summary&gt; static FormEx() { _globalBackgroundColor = default(Color?); } private static void InvalidateForms() { try { for (int i1 = 0; i1 &lt; Application.OpenForms.Count; i1++) { try { FormEx frm = (Application.OpenForms[i1] as FormEx); if (frm != null) { frm.Invalidate(true); frm.Refresh(); } } catch { //Should never happen } } } catch { //this will catch if the form count changes } } private static Color? _globalBackgroundColor; /// &lt;summary&gt; /// Sets the background color for all forms /// &lt;/summary&gt; public static Color? GlobalBackgroundColor { get { return FormEx._globalBackgroundColor; } set { if (FormEx._globalBackgroundColor != value) { FormEx._globalBackgroundColor = value; InvalidateForms(); } } } public override Color BackColor { get { return (_globalBackgroundColor == null ? base.BackColor : (Color)_globalBackgroundColor); } set { base.BackColor = value; } } /// &lt;summary&gt; /// Create a new colored form /// &lt;/summary&gt; public FormEx() : base() { } private void InitializeComponent() { this.SuspendLayout(); // // FormEx // this.ClientSize = new System.Drawing.Size(292, 266); this.Name = "FormEx"; this.Load += new System.EventHandler(this.FormEx_Load); this.ResumeLayout(false); } private void FormEx_Load(object sender, EventArgs e) { } } } </code></pre> <p>Since I am a beginner I am not able to understand how the above coding works. I found this coding while browsing through internet.</p> <p>The part I don't understand is this:</p> <pre><code>_globalBackgroundColor = default(Color?); </code></pre> <p>Why there is a <code>?</code> after the color, what does that indicate?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload