CPSC 481 Fateme Rajabiyazdi #W4. Visual Studio Download Visual Studio 2013 (Ultimate) from – MSDN...

Preview:

Citation preview

CPSC 481

Fateme Rajabiyazdi#W4

Visual Studio

• Download Visual Studio 2013 (Ultimate) from – MSDN Academic Alliance Software Center– IT email account • If you don’t have one, go to CPSC help desk and ask• Or email help desk, help@cpsc.ucalgary.ca

Starting a New Project

Click on File->New->Project

Click on Visual C# -> Console Application

The Workspace

Hello Word!

Hint: Use Console. Inside your main function

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;

namespace ConsoleTest{ class Program { static void Main(string[] args) { Console.WriteLine("Hello World"); } }}

BreakPoint : F9

Debugging - Watch

Naming Variables

• CamelCasing for variables– int MyInteger

• PascalCasing for methods– Public void HelloWorld(){…};

• Interfaces start with I• A good reference:http://www.csharpfriends.com/articles/getarticle.aspx?articleid=336

Commenting

• // Single line• /* Multi line */• /// This is how you describe methods

Access

• Public: accessible anywhere• Private: only accessible within the class• Protected: only accessible within the same

hierarchy

Properties

• Members that provide a mechanism to read, write or compute the values of private fields

• They expose a public way of getting and setting values, while hiding implementation.

• The Keyboard value defines the value being set• Properties without a set are read-only

Class TimePeriod{

private double seconds;public double Hours{

get {return seconds/3600;}public set { seconds = value *3600;}

}

Others…

• Class in C# are private by default• Booleans are “bool”• Instead of ArrayList<Type> , we have List<Type>• List.length -> list.Count

Recommended