Download presentation
Presentation is loading. Please wait.
1
GTECH 731 Lab Session 2 Lab 1 Review, Lab 2 Intro 9/6/10 Lab 1 Review Lab 2 Overview
2
Lab 1 – Review Visual Studio Integrated Development Environment (IDE) Review IDE Sections Main Window Start page – list of recent projects Program Code Tabs Solution Explorer Solution – Collection of projects Project – Collection of files supporting executable program Properties References – System files Code files –.CS files Properties Window – Settings for selected item Buttons across top Categorized / Alphabetical Properties / Events Windows Application Toolbox Objects that can be dragged onto Form
3
Lab 1 – Review Creating new project in Visual Studio (console or Windows) generates shell program with basic structure from which to build using System;// defines other namespaces in.Net Framework being used namespace HelloNameSpace// names of objects are declared as part of your program { public class HelloWorld// Everything in C# happens within a class { static void Main(string[] args)// “Main” Method is entry point to your console program { System.Console.WriteLine("Hello World!"); }// “System.” not necessary when “using System” line is used } } Curly braces define beginning and end of code defining an object Brackets placed at same indent level as object identifier Parentheses after method name is for “parameters” “Hello World!” string is parameter to “WriteLine” method
4
Lab 1 – Review Menu items View... Solution Explorer Properties Window Error List Debug F5 – Run program F10 – “Step Over” code and move to next line F11 – “Step Into” code do see where certain parts of program are executed Intellisense As you type, suggested Variables, Methods, Classes etc come up Different options appear depending on context
5
Lab 2 – Working with Variables & Operators Declaring and initializing a variable: int i;//declaration of variable “i” as integer i = 25;//initialization of variable “i” to value 25 the “=” sign is an “assignment” operator int i = 25;// declaration and initialization in one line Assigning value from method i = Convert.ToInt32(“25”); //assign variable “i” value 25 Operators +, -, *, /, = i = 2 + 2; // i equals 4 after this line i = 3 * 4;// i equals 12 after this line i = 3 * 4.2;// Error! Cannot convert from double to integer
6
Lab 2 – Working with Variables & Operators Naming conventions Member Variables should be nouns in “camel” notation Start with lowercase letter and init-cap words that make-up variable name Can start with lower case letter of the variable type int iMyInteger string sMyString float fMyFloatingPoint
7
Lab 2 – Working with Variables & Operators Overview Lab 2 – Console Overview Lab 2 – Windows
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.