Graphicsvar bmp = new Bitmap(400, 300)var g = Graphics.FromImage(bmp)Pen (width, color)Brush (px→color)SolidColorBrushLinearGradientBrushDrawRectangle() draws the border of a rectangleFillEllipse() fills an ellipse (could be circle)Image classBitmap classImage.FromFile() reads an image to an ImageSave() methodOnPaint()PaintEventArgsClipRectangle gives us the boundariesGraphics gives us the graphics pointerPaint eventListBox control) give us a third wayDrawMode and create an event handler (for DrawItem)Exception classthrow will throw an exception or re-throw the current exceptionvoid Main() { "Before".Dump(); Sub(); "After".Dump(); }void Sub() { "Enter".Dump(); throw new Exception("Bug"); }//Dump() is an extension that is like Console.WriteLine()
try { /* try here */ } catch { /* catch here /* }catch (Exception ex) {}catch (FileNotFoundException) {}finally {} block is usefulreturn in one block will still call the finallytry { "Try has been entered".Dump(); return true; }finally { "Finally has been called".Dump(); }
DynamicObject typedynamic a = 4var can be object or dynamicvar is no type, but a placeholderobject is the most general type; everything is an objectdynamic is no type, but a switchType is requiredtypeof() (at compile-time)GetType()Type object contains all information about the type