First C# Program
First C# Program
using System;
namespace Test
{
class ExampleClass
{
static void Main()
{
System.Console.WriteLine("Hello, world!");
}
}
}
Constructions of Note
•using
–like import in Java: bring in namespaces
•namespace
–disambiguation of names
–like Internet hierarchical names and C++ naming
•class
–like in C++ or Java
–single inheritance up to object
•static
void Main()
–Defines the entry point for an assembly.
–Four different overloads – taking string arguments and returning int’s.
•Console.Write(Line)
–Takes a formatted string: “Composite Format”
–Indexed elements: e.g., {0}
•can be used multiple times
•only evaluated once
–{index [,alignment][:formatting]}
Comments
Post a Comment