Command Line
Command Line: csc
Microsoft Resources
Rename and Refactor
1. Always rename your controls IMMEDIATELY
2. IF you forget:
the form
========
change the File name in the Solution Explorer
this changes the Name property too!
procedures
==========
Refactor a procedure name using Refactor Menu
Form1_load becomes frmMain_Load
buttons and other controls
==========================
change the Name property in Properties window
Refactor a procedure name using Refactor Menu
button1_Click becomes btnNewName_Click
variables
=========
highlight the variable
right-click
refactor
rename
changes names according to scope rules
better than search/replace!
Expand & Collapse Outlining
existing collapsible regions
each method [+] contracated
[-] expanded
hides complexity while coding
INCLUDE at leat one line of comment above the method
create NEW collapsible regions
#region FindPrimeNumber
#endregion
UN-Wiring: deleting event code in c# windows programs
1.
after deleting an event handler method, the code attaching the event to
the object is still there & will cause an error
must delete line of code that adds event handler to object
in Form1.Designer.cs
code will look similar to this:
this.button4.Click += new System.EventHandler(this.button4_Click);
DELETE!
2.
goto properties of the control with the handler to delete
choose the events tab
in events use RESET to UN-wire event
Wiring: adding event code in c# windows programs
To wire a method to an event
goto properties of the control with the handler to delete
choose the events tab
in events choose the proper event
choose the method from the drop-down to wire event
Debugger & Debug Output
F5
breakpoint
step into / over / out
examine / watch
Microsoft: using the debugger
In console AND windows can output that will occur ONLY in debug (F5)
Need this:
using System.Diagnostics; // for debug write
Can write as follows to display the value of x:
Debug.WriteLine( x.ToString() ); // writes to output window in IDE
Tools / Options
turn on line numbers
set tabs
Organize usings
right-click code window
organize using
remove unused usings
To RESET the Layout: Reset Window Layout from the Window menu in the Visual Studio