Hello World in C#: Using System Public Class Myapp (Public Static Void Main (Console - Writeline ("Hi From C#") ) )
Hello World in C#: Using System Public Class Myapp (Public Static Void Main (Console - Writeline ("Hi From C#") ) )
NET Namespaces
Each of us understands the importance of code libraries.
The point of libraries such as MFC, J2EE, is to give
developers a well-defined set of existing code to leverage
in their applications.
For example, MFC defines a number of C++ classes that
provide canned implementations of dialog boxes, menus,
and toolbars. This is a good thing for the MFC
programmers of the world, as they can spend less time
reinventing the wheel, and more time building a custom
solution.
Visual Basic and Java offer similar notions: intrinsic
types/global functions and packages, respectively.
Unlike MFC, Java, or Visual Basic 6.0, the C# language
does not come with a predefined set of language specific
classes. Ergo, there is no C# class library. Rather, C#
developers leverage existing types supplied by the .NET
Framework.
To keep all the types within this binary well organized,
the .NET platform makes extensive use of the namespace
concept.
The key difference between this approach and a languagespecific library such as MFC, is that any language
targeting the .NET runtime makes use of the same
namespaces and same types as a C# developer.
For example, the following three programs all illustrate the
ubiquitous "Hello World" application, written in C#, VB
.NET, and C++ with managed extensions (MC++):
// Hello world in C#
using System;
public class MyApp
{
public static void Main()
{
Console.WriteLine("Hi from C#");
}
}
' Hello world in VB .NET
Imports System
Public Module MyApp
Sub Main()
Console.WriteLine("Hi from VB .NET")
End Sub
End Module
.NET Namespaces
System
System.Collections
Meaning
Within
System
you
find
numerous low-level classes
dealing
with
primitive
types,
mathematical manipulations,
garbage
collection, as well as a number
of commonly used exceptions
and predefined attributes.
This namespace defines a
number of stock container
objects
(ArrayList, Queue, etc.) as well
as base types and interfaces
that allow you to build
System.Data
System.Data.Common
System.Data.OleDb
System.Data.SqlClient
System.Drawing
System.Drawing.Drawing2D
System.Drawing.Printing
System.IO
System.Security
System.Web
customized collections
These namespaces are
course) used for database
manipulations (ADO.NET).
(of