Professional Documents
Culture Documents
Avanade Capability - NET - CSharp - Module 2 - Overview of CSharp
Avanade Capability - NET - CSharp - Module 2 - Overview of CSharp
Avanade Capability - NET - CSharp - Module 2 - Overview of CSharp
Overview of C#
• Structure of a C# Program
• Basic Input/Output Operations
• Documenting an Application
• Debugging Applications by Using Visual Studio 2010
• Hello, World
• The Class
• The Main Method
• The using Directive and the System Namespace
• Demonstration: Using Visual Studio to Create a C#
Program
[2.1.1 Structure]
Bring System namespace into scope
using System;
Namespace declaration
namespace MyFirstApplication
{ Program class declaration
class Hello
{
static void Main( ) Main method declaration
{
Console.WriteLine(“Hello, World”);
}
}
}
Write()
WriteLine()
Read()
ReadKey()
ReadLine()
Clear()
[2.2.1 Write / 2.2.2 WriteLine / 2.2.3 Read / 2.2.4 ReadKey / 2.2.5 ReadLine / 2.2.6 Clear]
using System;
...
Console.WriteLine("Hello there!“);
© Copyright 2011 Avanade Inc. All Rights Reserved. 12
Text Formatting
Item Meaning
Item Meaning
<summary> … </summary>
<remarks> … </remarks>
<example> … </example>
<code> … </code>
<returns> … </returns>
<?xml version="1.0"?>
<doc>
<assembly> <name>MyProject</name></assembly>
<members>
<member name="T:Hello">
<summary> The Hello class prints a greeting on the screen
</summary>
</member>
<member name="M:Hello.Main">
...
</member>
</members>
</doc>
• If there are no errors, you can view the XML file that is
generated by using a tool such as Internet Explorer.
using System;
public class Hello
{
public static void Main(string[ ] args)
{
try{
Console.WriteLine(args[0]);
}
catch (Exception e) {
Console.WriteLine("Exception at
{0}", e.StackTrace);
}
}
}
• Review Questions
• Best Practices