1 / 7

Getting Started with C#

Getting Started with C#. August 29, 2005. .NET Concepts. Language Independence Language Integration your C# program can use a class written in VB Program are compiled into "assemblies" of "microsoft intermediate language" code

shel
Télécharger la présentation

Getting Started with C#

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Getting Started with C# August 29, 2005

  2. .NET Concepts • Language Independence • Language Integration • your C# program can use a class written in VB • Program are compiled into "assemblies" of "microsoft intermediate language" code • When a program is run, the IL is compiled into machine code by the Just-In-Time compiler

  3. Some Features of C# • Completely Object-Oriented • even main() must be part of a class • Syntax is very similar to C++ • for loops and comments are the same • IO is different • Garbage collection is automatic • Strongly Typed • Variables must be initialized before their use

  4. Hello World - 1.0 class Class1 { static void Main() { System.Console.WriteLine("Hello World"); } }

  5. Hello World - 1.1 #region Compiler Directives using System; #endregion namespace Test2 { class MainProgram { static void Main() { DateTime today = DateTime.Now; // sample variable Console.Write("Hello, "); Console.WriteLine("Today is {0}/{1}/{2}", today.Month, today.Day, today.Year); } } }

  6. Hello World - 1.1 Allows the editor to compress this code into a single line #region Compiler Directives using System; #endregion namespace Test2 { class MainProgram { static void Main() { DateTime today = DateTime.Now; // sample variable Console.Write("Hello, "); Console.WriteLine("Today is {0}/{1}/{2}", today.Month, today.Day, today.Year); } } } less typing required, but System.Console is not legal Just in case another class is named MainProgram Print the value of a variable Declaration and Initialization the Month property of the today instance Just like C++

  7. Using MS Visual Studio • Open MS Visual Studio .NET via the Start menu • Open a new project • select both "C#" and "Console Application" • rename the project to something such as "lab01" • hit "OK" • Get rid of all the junk the editor added for you • string[] args • etc… • Enter your source code • To compile: Build -> Build Solution • To run: Debug -> Start without Debugging

More Related