Getting Started Example ICS2O curriculum Visual Studio C# Getting Started Example ICS2O curriculum
C# Language Overview "C# is intended to be a simple, modern, general-purpose, object-oriented programming language" Developed by Anders Hejlsberg 15 years old – created after Java
Top 10 Programming Languages C# is number 4 IEEE Spectrum, July 19 2014 Stephen Cass Based on "12 metrics from 10 sources (including IEEE Xplore, Google, and GitHub) to rank the most popular programming languages"
The .NET Framework collection of software/libraries used by Windows applications C# is one of many languages supported by .NET
Types of Projects Graphical / Forms Text / Console
Project Name You can specify the project name as you create a new project or as you save a project This is where the solution folder will be created Project name Project name Solution name
Console Applications Hello World
DESIGN MODE Forms Applications RUN MODE
Visual Studio Modes Visual Studio has 2 different modes Design Runtime Control properties can be modified at design time (static), or while the program is running (dynamic)
Visual Studio Environment Visual Studio is a professional integrated development environment (IDE) Tools: Designer Window (1) Solution Explorer Window (2) Properties Window (3) Free versions are available as Visual Studio Express on Microsoft's website (2) (1) (3)
Forms Basics TOOLBOX Form is a container for the controls that the user will use while the program is executing. Add controls from the toolbox
Objects Objects are created from their associated Class A Class is like a blueprint which defines the properties and methods/tasks. Form object Label objects TextBox objects Button objects
First Set of Controls Forms, Labels, Textboxes, Buttons Form - window that is displayed on the screen which contains other objects. Label – displays text within a Form TextBox – defined region used to accept text input from a user Button – defined area that is used to start an event generated by the user Note: Most of your application code will be associated with a Button Click event. If you double click on Control you will have the opportunity to view/modify the code or actions that will occur when the event happens.
Using TextBox for Input GUI control object that is used to obtain keyboard input from the user Example string name = txtName.Text; int age = int.Parse(txtName.age);
Using Buttons for Events Control object for user-generated events. Write code behind for a Button Click
Using Labels for Output GUI control object that is used to display text at a specific location on a form Example lblMessage.Text = "Some Message"; The displayed text is defined by the Text property of the Label The data on the left side of the = operator must be a string
Using Textbox for Output GUI control object that is used to display or obtain text at a specific location on a form Example tbMessage.Text = "Some text message"; Set the property ReadOnly to True to displaying text
Using Dialogs as Output Message box a small window (dialog box) that displays a text Example MessageBox.Show("Some text message"); MessageBox is a Class and not a control on a form To create a message box you call the Show method on the Class. The argument that is passed must be a string
ICS2O Curriculum Console / GUI Random Listbox Math operations Picturebox (GUI) Files Variables Timers (GUI) 1D Array Data type conversions User input (GUI) radio buttons / checkboxes Selection if / booleans Conditional Loops Counted loops (for)
Resources Used