1. General structure of a C# program
A C# programs can consist of one or more files. Every file can contain zero, one or more namespaces. A namespace contains types for example classes, structs, interfaces, enumerations, and delegates, or other namespaces. See Code Snippet 2.1 for the structure or draft of a C# program that contains all of those elements.
Code snippet 2.1:
// A draft of a C# program using System;
namespace ProjectNamespace
{class MyClass
{ } struct MyStruct
{ } interface IMyInterface
{ } delegate int MyDelegate();
enum MyEnum
{ } namespace MyNestedNamespace
{struct MyAnotherStruct
{ } } class MyMainClass
{static void Main(string[] args)
{//My program starts here...
} }} Code explanation 2.1:
using is the keyword used to include any namespace in our program
namespace is the keyword used to declare any new namespace will be dealt in detail
class is keyword used to define a class will be dealt in detail
struct keyword is used to declare a structure as in c
interface keyword is used to create interface which can be implemented later we will discuss it later in detail
enum is used to create enums we will discuss it in detail in following articles
static void Main(string[] args) is the entry point for the program
Regards,Meetu Choudhary
No comments:
Post a Comment