| C Sharp |
| Programming Language - To Write/Code C# Programs |
| Designed and Created for .NET | |
| Code Snippet | |
| C# | class MyClass { static void Main() { } } |
| Object-Oriented, Component-Oriented, Type-Oriented etc. : Feature | |
| High Level, Block Structured, Case Sensitive and Free-Form Language | |
| C# Program |
| C# Instruction - To Perform Specific Tasks |
| Combination of Tokens, Comments and White Spaces | |
| Code Snippet | |
| C# Program | /* File : MyProgram.cs */ namespace MyNamespace { class MyClass { static void Main(string[] myParameters) { // Write to Console System.Console.WriteLine("Hello, World"); } } } |
| namespace, MyNamespace, {}, class, MyClass, static, void, Main, (), string, [], myParameters, ., "Hello, World", ; : Token /* File : MyProgram.cs */, // Write to Console : Comment Space Character, Tab Character, New Line Character : White Space | |
| Traditional Program to Display a Line of Text Hello, World | |
| Token |
| Smallest Element of Program |
| Recognized by the Compiler | |
| Code Snippet | |
| C# Token | Keyword, Identifier, Literal, Punctuator etc. |
| namespace, class, static, void, string : Keyword Token MyNamespace, MyClass, Main, myParameters : Identifier Token "Hello, World" : Literal Token {}, (), [], ., "", ; : Punctuator Token | |
| Comment and White Space are Separator, Not Token | |
| Comment |
| Enhance Understanding of Program |
| Ignored by the Compiler | |
| Code Snippet | |
| C# Comment | /* File : MyProgram.cs */ // Write to Console |
| /**/ : Multi Line Comment // : Single Line Comment | |
| Play Important Role, In the Maintenance of Program | |
| White Space |
| Enhance Readability of Program |
| Extra White Spaces Ignored by the Compiler | |
| Code Snippet | |
| C# White Space | Space Character, Tab Character, New Line Character etc. |
| Space Character : Space White Space Tab Character : Tab White Space New Line Character : New Line White Space | |
| To Act as Token Separator, At Least One White Space Character | |
| Keyword |
| Reserved Identifier, Vocabulary of Language |
| Special Meaning to the Compiler | |
| Code Snippet | |
| C# Keyword | namespace, class, static, void, string etc. |
| namespace : Namespace Keyword class : Class Keyword static : Static Keyword void, string : Type Modifier Keyword | |
| To Use as Programmer Identifier, Prefix @ Character | |
| Identifier |
| Naming Namespace, Class, Method, Parameter etc. |
| Programmer Defined Token | |
| Code Snippet | |
| C# Identifier | MyNamespace, MyClass, Main, myParameters etc. |
| MyNamespace : Namespace Identifier MyClass : Class Identifier Main : Method Identifier myParameters : Parameter Identifier | |
| Remember, Cannot Start with Digit Character | |
| Literal |
| Fixed Values and Expression Results |
| Hard Coded Values Constant | |
| Code Snippet | |
| C# Literal | "Hello, World" etc. |
| "Hello, World" : String Literal | |
| Only Legal and Valid Values are Permitted | |
| Punctuator |
| Separate and Group Block of Code |
| Also Known As Separator | |
| Code Snippet | |
| C# Punctuator | {}, (), [], ., "", ; etc. |
| {} : Braces Punctuator () : Parentheses Punctuator [] : Brackets Punctuator . : Period Punctuator "" : Double Quotes Punctuator ; : Semi Colon Punctuator | |
| Generally, Define Scope and Shape of Program | |
| Program Structure |
| Structure and Layout of Program |
| Multiple Coding Blocks | |
| Code Snippet | |
| C# Program Structure | Documentation Directive Namespace Type Member Statement |
| Proprietary, File, Version, Author etc. : Documentation Using Directive etc. : Directive Namespace etc. : Namespace Class, Struct, Interface etc. : Type Field, Property, Method etc. : Member Declaration Statement, Expression Statement etc. : Statement | |
| Readable, Understandable and Maintainable Program Structure | |
| Namespace |
| Logically Group Types |
| Build Hierarchy | |
| Code Snippet | |
| C# Namespace | namespace System {} |
| System : Namespace | |
| To Import Namespace, Use Using Directive | |
| Class |
| Encapsulate Data and Members |
| Reference Type | |
| Code Snippet | |
| C# Class | public static class Console {} |
| Console : Class | |
| Implicitly, Class Inherits from System.Object | |
| Method |
| Set and Group of Statements |
| Such as Static, Instance etc. | |
| Code Snippet | |
| C# Method | pubic static void WriteLine(string value) {} |
| WriteLine : Method | |
| To Access Static Method, Use Type Name | |
| Parameter |
| Arguments of Method |
| Such as Value, Reference, Output etc. | |
| Code Snippet | |
| C# Parameter | pubic static void WriteLine(string value) {} |
| value : Parameter | |
| To Pass By Reference and Output, Use ref and out Keyword | |
| Method Invocation |
| Call and Execute Statement |
| Followed By Parentheses () | |
| Code Snippet | |
| C# Method Invocation | System.Console.WriteLine("Hello, World"); |
| System.Console.WriteLine() : Method Invocation | |
| To Terminate the Statement, Use Semi Colon ; Character | |
| Main Method |
| Starting and Entry Point of Program |
| Initiate the Program Execution | |
| Code Snippet | |
| C# Main Method | static void Main(string[] myParameters) {} |
| Main : Method | |
| To Specify Type of Main Method, CMD@ csc.exe /main | |
| Command Line Arguments |
| Parameters of Main Method |
| Provided at Time of Execution | |
| Code Snippet | |
| C# Command Line Arguments | static void Main(string[] myParameters) {} |
| myParameters : Command Line Arguments | |
| To Pass Arguments, CMD@ {Application}.exe [Arg1] [Arg2] ... | |
