Posted on Leave a comment

C# Programming Notes

Microsoft Visual Studio 2012

View the UI Form Designer

View, Solution Explorer
Right-click on Form class (“Form1.cs”)
Select “View Designer”

If error prevents display, close designer window with error message,
reopen (see above)

Add new class

Project, Add Class

Add general purpose classes from other projects

File, Add, New Project (or Existing Project) e.g., \C#l\Utility1

Add various cs files to that project, one for each class
e.g., Reg.cs, CString.cs, Trial.cs

Solution Explorer

References, Right click, “Add Reference”
Solutions, Project, select the new project (.csproj)

pass by reference

add “ref” to both caller and method
mymethod(ref string istr) { …
x.mymethod(ref mystr);

Make classes public unless they’re only support for other classes in assembly (“internal”)

Override and virtual

mark methods to override as “virtual” and subclassed methods “override”

Leave a Reply

Your email address will not be published. Required fields are marked *