Issuu on Google+

Creating Your First C# Application A Basic Introduction to the C# Language ____________________________________________ Š Dragonfly Tech 2009


IT ONLY TAKES A MINUTE TO CREATE A C# APPLICATION. FOLLOW THESE STEPS TO CREATE A PROGRAM THAT OPENS A WINDOW AND REACTS TO A BUTTON PRESS.

PROCEDURES TO CREATE A C# APPLICATION 1. ON THE FILE MENU, POINT TO NEW, AND THEN CLICK PROJECT. 2. ENSURE THE WINDOWS APPLICATION TEMPLATE IS SELECTED, IN THE NAME FIELD, TYPE MY PROJECT, AND CLICK OK. YOU WILL SEE A WINDOWS FORM IN THE WINDOWS FORMS DESIGNER. THIS IS THE USER INTERFACE FOR YOUR APPLICATION. 3. ON THE VIEW MENU, CLICK TOOLBOX TO MAKE THE LIST OF CONTROLS VISIBLE. 4. EXPAND THE COMMON CONTROLS LIST, AND DRAG THE LABEL CONTROL TO YOUR FORM. 5. ALSO FROM THE TOOLBOX COMMON CONTROLS LIST, DRAG A BUTTON ONTO THE FORM, NEAR THE LABEL. 6. DOUBLE-CLICK THE NEW BUTTON TO OPEN THE CODE EDITOR. VISUAL C# HAS INSERTED A METHOD CALLED BUTTON1_CLICK THAT IS EXECUTED WHEN THE BUTTON IS CLICKED. 7. CHANGE THE METHOD TO LOOK LIKE THIS: private void button1_click(object sender, eventargs e) { label1.text = "hello, world!"; }

8. PRESS F5 TO COMPILE AND RUN YOUR APPLICATION. WHEN YOU CLICK THE BUTTON, A TEXT MESSAGE IS DISPLAYED. CONGRATULATIONS! YOU'VE JUST WRITTEN YOUR FIRST C# APPLICATION.


CREATING YOUR FIRST C# APPLICATION