Download presentation
Presentation is loading. Please wait.
1
Distributed Systems Tutorial 1 - Getting Started with Visual C#.NET
2
2 Course Info Home page: http://webcourse.cs.technion.ac.il/236351http://webcourse.cs.technion.ac.il/236351 Three Mandatory Programming Assignments Requirements: Working knowledge of Java / C# Basic knowledge of OOP concepts Basic knowledge of network concepts (sockets, protocols) No textbook, look at the home page for manuals, tutorials and additional resources
3
3 Hello World application Development in Visual Studio is organized around solutions, which contain one or more projects. For this tutorial, we will create a solution with a single C# project. Creating a New Project In the Visual Studio.NET environment, select File | New | Project from the menu.
4
4 Hello World application cont. Select Visual C# Projects on the left and then Console Application on the right..
5
5 Specify the name of your project and enter the location in which to create the project. The project directory will be created automatically by Visual Studio Click OK and you're on your way!
6
6 Class1.cs using System; namespace HelloWorld { class Class1 { static void Main(string[] args) { Console.WriteLine("Hello C# World!"); }
7
7 Namespaces Namespaces are used to define scope in C# applications Multiple source code files can contribute to the same namespace The using directive permits you to reference classes in the namespace without using a fully qualified name class Class1 { static void Main(string[] args) { System.Console.WriteLine ("Hello, C#.NET World!"); } }
8
8 Namespaces cont. using System; class Class1 { static void Main(string[] args) { Console.WriteLine ("Hello, C#.NET World!"); } } When the compiler parses theConsole.WriteLine method, it will determine that the method is undefined. It will search through the namespaces specified with the using directives and will find the method in the System namespace and will compile the code.
9
9 Namespaces cont. Note that using directive applies to namespaces and not to classes In the example: System is the namespace Console is the class WriteLine is a static method belonging to Console Therefore the following code would be invalid:
10
10 using System.Console; // ERROR: Can’t use a using directive with a class class Class1 { static void Main(string[] args) { WriteLine ("Hello, C#.NET World!"); } } But its possible: using output = System.Console; //alias output.WriteLine(“Hello, C#.NET World”);
11
11 Skeleton using namespace class { public static void Main() { // TODO: Add code to start application here } } Notice that the angle brackets denote where you need to supply information.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.