Hello. I am receiving a compile error:
Use of unassigned local variable 'defBrush' (CS0165)
How is defBrush out of scope? Looks to be in perfect scope and this doesn't make any sense to me. The instance that it is barking at is highlighted in red below. Funny how it doesn't bark at the previous usages of defBrush in this loop. I have tried instantiating defBrush inside the do-while loop as well and it doesn't work. The only place it works is directly inside the 'if' block it's barking at. Appreciate any help.
Code:Brush defBrush; this.defectList.refDef = this.defectList.head; do { xPos = ((mapSpacePixelWidth / this.mapWidth) * this.defectList.refDef.crosswebPos); // Pixel location yPos = ((mapSpacePixelLength / this.mapLength) * this.defectList.refDef.downwebPos); // Pixel location defType = this.defectList.refDef.type; if (defType.Contains("Trans")) defBrush = new SolidBrush(Color.Yellow); else if (defType.Contains("Refl")) defBrush = new SolidBrush(Color.Red); else if (defType.Contains("Inspection")) defBrush = new SolidBrush(Color.Violet); else if (defType.Contains("Coating")) defBrush = new SolidBrush(Color.Cyan); else if (defType == "Splice") defBrush = new SolidBrush(Color.White); else if (defType == "Bar Mark") defBrush = new SolidBrush(Color.Silver); else MessageBox.Show("New Type discovered: " + defType); if (defType.Contains("vSml")) this.gfxMap.FillEllipse(defBrush, xPos+this.mapMarginLeft-2, yPos+this.mapMarginTop-2, 4, 4); else if (defType.Contains("Sml")) this.gfxMap.FillEllipse(defBrush, xPos+this.mapMarginLeft-4, yPos+this.mapMarginTop-4, 8, 8); else if (defType.Contains("Med")) this.gfxMap.FillEllipse(defBrush, xPos+this.mapMarginLeft-6, yPos+this.mapMarginTop-6, 12, 12); else if (defType.Contains("Lrg")) this.gfxMap.FillEllipse(defBrush, xPos+this.mapMarginLeft-8, yPos+this.mapMarginTop-8, 16, 16); else if (defType.Contains("Streak")) this.gfxMap.FillRectangle(defBrush, xPos+this.mapMarginLeft-6, yPos+this.mapMarginTop-11, 12, 22); else




Reply With Quote