CPSC 481 – Tutorial 4
Intro to Visual Studio and C#
Brennan Jones bdgjones@ucalgary.ca (based on previous tutorials by Alice Thudt, Fateme Rajabiyazdi, and David Ledo)
CPSC 481 Tutorial 4 Intro to Visual Studio and C# Brennan Jones - - PowerPoint PPT Presentation
CPSC 481 Tutorial 4 Intro to Visual Studio and C# Brennan Jones bdgjones@ucalgary.ca (based on previous tutorials by Alice Thudt, Fateme Rajabiyazdi, and David Ledo) Announcements I emailed you an example showing how the evolved
Brennan Jones bdgjones@ucalgary.ca (based on previous tutorials by Alice Thudt, Fateme Rajabiyazdi, and David Ledo)
prototype and walkthrough should be presented in your portfolio.
together your portfolios.
machine for free here
MSDN
CPSC help desk (just outside our tutorial room) and ask for one.
usernames you wish to have access to it
We won’t go over this in tutorial, but here are some resources that can help you:
http://grouplab.cpsc.ucalgary.ca/cookbook/index .php/VisualStudio/Subversion
http://tortoisesvn.net/visualstudio.html
click
click
click
change
coding area
solution explorer
run your program
click to create a breakpoint
call stack and variables
debug functions: run, pause, stop, restart
Studio
Sources/Materials:
us/library/aa288436(v=vs.71).aspx
for variables and PascalCasing for methods.
int myInteger; public void ReturnResults(){ … }
starting with an underscore:
int _myInteger
// This is a single-line comment /* This is a multi-line comment */ /// This is how you describe methods /** (This is how you describe methods in Java) */
public – accessible anywhere private – only accessible within the class or struct protected – only accessible within the same hierarchy internal – only accessible by the same assembly
mechanism to read, write, or compute the value of a private field.
getting and setting values, while hiding implementation or verification code.
class TimePeriod { private double seconds; public double hours { get { return seconds / 3600; } set { seconds = value * 3600; } } }
the set accessor.
class Program { static void Main() { TimePeriod t = new TimePeriod(); // Assigning the Hours property causes the 'set' accessor to be called. t.Hours = 24; // Evaluating the Hours property causes the 'get' accessor to be called. System.Console.WriteLine("Time in hours: " + t.Hours); } } // Output: Time in hours: 24
using System.Collections; ArrayList list = new ArrayList(); list.Add(1); list.Add(2); foreach (int i in list) { int j = i; }
If you use generic containers (e.g., ArrayList), casting is implicit, unlike Java where you have to explicitly cast.
A class can inherit a base class and also implement
public class ChildClass : InterfaceName public class ChildClass : ParentClass public class ChildClass : ParentClass, IInterface1, IInterface2 …
Based on your walkthrough and the problems you have identified, create updated designs for your prototype that incorporate your solutions.
your portfolio