SlideShare a Scribd company logo
C# and F#Programming Language
C SHARPIt was developed by Microsoft within its .NET initiative and later approved as a standard by Ecma (ECMA-334) and ISO (ISO/IEC 23270). C# is one of the programming languages designed for the Common Language Infrastructure."C sharp" was inspired by musical notation where a sharp indicates that the written note should be made a semitone higher in pitch.C#'s principal designer and lead architect at Microsoft is Anders Hejlsberg, who was previously involved with the design of Turbo Pascal, Embarcadero Delphi.
Design Goals of C#C# language is intended to be a simple, modern, general-purpose, object-oriented programming language.The language, and implementations thereof, should provide support for software engineering principles such as strong type checking, array bounds checking, detection of attempts to use uninitialized variables, and automatic garbage collection.The language is intended for use in developing software components suitable for deployment in distributed environments.Source code portability is very important, as is programmer portability, especially for those programmers already familiar with C and C++.
Design Goals of C#Support for internationalization is very important.C# is intended to be suitable for writing applications for both hosted and embedded systems, ranging from the very large that use sophisticated operating systems, down to the very small having dedicated functions.Although C# applications are intended to be economical with regard to memory and processing power requirements, the language was not intended to compete directly on performance and size with C or assembly language.
Versions of C#
Distinguishing Features of C#It has no global variables or functions. All methods and members must be declared within classes. Static members of public classes can substitute for global variables and functions.Local variables cannot shadow variables of the enclosing block, unlike C and C++. Variable shadowing is often considered confusing by C++ texts.C# supports a strict Boolean data type.In C#, memory address pointers can only be used within blocks specifically marked as unsafe, and programs with unsafe code need appropriate permissions to run. Managed memory cannot be explicitly freed.
Distinguishing Features of C#Multiple inheritance is not supported, although a class can implement any number of interfaces.C# is more type safe than C++. C# currently (as of version 4.0) has 77 reserved words.
Categories of data typesValue typesValue types are plain aggregations of data. Instances of value types do not have referential identity nor a referential comparison semantics - equality and inequality comparisons for value types compare the actual data values within the instances, unless the corresponding operators are overloaded.
Examples of value types are all primitive types, such as int (a signed 32-bit integer), float (a 32-bit IEEE floating-point number), char (a 16-bit Unicode code unit), and System.DateTime (identifies a specific point in time with nanosecond precision).Categories of data typesReference typesreference types have the notion of referential identity - each instance of a reference type is inherently distinct from every other instance, even if the data within both instances is the same.
Examples of reference types are object (the ultimate base class for all other C# classes), System.String (a string of Unicode characters), and System.Array (a base class for all C# arrays).Code commentsC# utilizes a double forward slash (//) to indicate the rest of the line is a comment. This is inherited from C++.public class Foo{    // a comment    public static void Bar(intfirstParam) {}  // also a comment}Multi-line comments can be indicated by a starting forward slash/asterisk (/*) and ending asterisk/forward slash (*/). This is inherited from standard C.public class Foo{/* A Multi-Line       comment  */    public static void Bar(intfirstParam) {}}
PreprocessorC# features "preprocessor directives" (though it does not have an actual preprocessor) based on the C preprocessor that allow programmers to define symbols but not macros. Conditionals such as #if, #endif, and #else are also provided. Directives such as #region give hints to editors for code folding.public class Foo{#region Procedures    public void IntBar(intfirstParam) {}    public void StrBar(string firstParam) {}    public void BoolBar(bool firstParam) {}    #endregion    #region Constructors    public Foo() {}    public Foo(intfirstParam) {}    #endregion}
"Hello world" exampleusing System;class Program{    static void Main()    {Console.WriteLine("Hello world!");    }}
using System;The using statement allows the programmer to state all candidate prefixes to use during compilation instead of always using full type names.class ProgramAbove is a class definition. Everything between the following pair of braces describes Program.static void Main()This declares the class member method where the program begins execution. The void keyword declares that Main has no return value.Console.WriteLine("Hello world!");The program calls the Console method WriteLine, which displays on the console a line with the argument, the string "Hello world!".Comparison of C Sharp and JavaBoth languages are considered "curly brace" languages in the C/C++ family. Overall the syntaxes of the languages are very similar.The syntax at the statement and expression level is almost identical with obvious inspiration from the C/C++ tradition.Java is explicit about extending classes and implementing interfaces, while C# infers this from the kind of types a new class/interface derives from.C# supports more features than Java which to some extent is also evident in the syntax which specifies more keywords and more grammar rules than Java.
Simple/primitive types
Advanced numeric types
Lifted (nullable) types
Special feature keywords
Special feature keywords
C Sharp IdentifierAn identifier can:start with a "_".
contain both upper case and lower case Unicode letters. Case is significant.An identifier cannot:start with a numeral.
start with a symbol, unless it is a keyword (check Keywords).
have more than 511 chars.C# keywords, reserved words
C Sharp Literals
C Sharp Literals
 VariablesVariables are identifiers associated with values. They are declared by writing the variable's type and name, and are optionally initialized in the same statement by assigning a value.DeclareintMyInt;         // Declaring an uninitialized variable called 'MyInt', of type 'int'InitializeintMyInt;        // Declaring an uninitialized variableMyInt = 35;       // Initializing the variableDeclare & initializeintMyInt = 35;   // Declaring and initializing the variable at the same time
 Operators
Conditional structuresif statementThe if statement is entered when the given condition is true. Single-line case statements do not require block braces although it is mostly preferred by convention.Simple one-line statement:if (i == 3) ... ;Multi-line with else-block (without any braces):if (i == 2)    ...else    ...
Conditional structuresswitch statementThe switch construct serves as a filter for different values. switch (ch){case 'A':        ...        break;    case 'B':    case 'C':         ...         break;    default:        ...        break;}
Jump statementsThe goto statement can be used in switch statements to jump from one case to another or to fall through from one case to the next.switch(n){    case 1:Console.WriteLine("Case 1");        break;    case 2:Console.WriteLine("Case 2");goto case 1;    case 3:Console.WriteLine("Case 3");    case 4: // Compilation will fail here as cases cannot fall through in C#.Console.WriteLine("Case 4");goto default; // This is the correct way to fall through to the next case.    default:Console.WriteLine("Default");}
Iteration structureswhile loopwhile (i == true){    ...}do ... while loopdo{    ...}while (i == true);for loopThe for loop consists of three parts: declaration, condition and increment. Any of them can be left out as they are optional.for (int i = 0; i < 10; i++){    ...}
break statementThe break statement breaks out of the closest loop or switch statement. Execution continues in the statement after the terminated statement, if any.int e = 10;for (int i=0; i < e; i++){    while (true)    {        break;    }    // Will break to this point.}
continue statementThe continue statement discontinues the current iteration of the current control statement and begins the next iteration.intch;while ((ch = GetChar()) >= 0){    if (ch == ' ')        continue;    // Skips the rest of the while-loop    // Rest of the while-loop    ...}
ModifiersModifiers are keywords used to modify declarations of types and type members. Most notably there is a sub-group containing the access modifiers.abstract - Specifies that a class only serves as a base class. It must be implemented in an inheriting class.
const - Specifies that a variable is a constant value that has to be initialized when it gets declared.
event - Declare an event.
extern - Specify that a method signature without a body uses a DLL-import.
override - Specify that a method or property declaration is an override of a virtual member or an implementation of a member of an abstract class.
readonly - Declare a field that can only be assigned values as part of the declaration or in a constructor in the same class.
sealed - Specifies that a class cannot be inherited.
static - Specifies that a member belongs to the class and not to a specific instance. (see section static)
unsafe - Specifies an unsafe context, which allows the use of pointers.
virtual - Specifies that a method or property declaration can be overridden by a derived class.
volatile - Specifies a field which may be modified by an external process and prevents an optimizing compiler from modifying the use of the field.FSHARPF# is a multi-paradigm programming language, targeting the .NET Framework, that encompasses functional programming as well as imperative and object-oriented programming disciplines.It is a variant of ML and is largely compatible with the OCaml implementation.F# was initially developed by Don Syme at Microsoft Research but is now being developed at Microsoft Developer Division and is being distributed as a fully supported language in the .NET Framework and Visual Studio as part of Visual Studio 2010.F# is a strongly typed language that uses type inference.
F SHARPF# uses pattern matching to resolve names into values. It is also used when accessing discriminated unions.F# comes with a Microsoft Visual Studio language service that integrates it with the IDE.All functions in F# are instances of the function type, and are immutable as well.The F# extended type system is implemented as generic .NET types.
ExamplesA few small samples follow:(* This is a comment *)(* Sample hello world program *)printfn "Hello World!"
 Operators
Operators
Functions

More Related Content

PDF
Learn C# Programming - Decision Making & Loops
PPT
Csharp4 basics
DOCX
Unit 1 question and answer
PPT
Lecture 1
PDF
Learning c - An extensive guide to learn the C Language
PPT
5 introduction-to-c
PPTX
CSharp Presentation
DOCX
Learn C# Programming - Decision Making & Loops
Csharp4 basics
Unit 1 question and answer
Lecture 1
Learning c - An extensive guide to learn the C Language
5 introduction-to-c
CSharp Presentation

What's hot (18)

PDF
Top C Language Interview Questions and Answer
PPTX
C++ programming language basic to advance level
PDF
New c sharp4_features_part_ii
PPTX
Python Interview questions 2020
PDF
Language tour of dart
PPTX
C programming interview questions
PPSX
C# - Part 1
PDF
CSharp difference faqs- 1
DOCX
Complete c programming presentation
PPTX
C sharp
PDF
Deep C
PPTX
Switch case and looping
PDF
PPTX
C# lecture 2: Literals , Variables and Data Types in C#
PDF
88 c-programs
PDF
C reference manual
PPT
Javascript by Yahoo
PPTX
C#unit4
Top C Language Interview Questions and Answer
C++ programming language basic to advance level
New c sharp4_features_part_ii
Python Interview questions 2020
Language tour of dart
C programming interview questions
C# - Part 1
CSharp difference faqs- 1
Complete c programming presentation
C sharp
Deep C
Switch case and looping
C# lecture 2: Literals , Variables and Data Types in C#
88 c-programs
C reference manual
Javascript by Yahoo
C#unit4
Ad

Viewers also liked (9)

PPTX
Transportation
PPTX
Age Awareness
PPTX
c# at f#
PDF
Apresentação bizmeet
PDF
Disability Discrimination Month
PDF
Celebrate Italian, Polish and Native American Heritage in October
PDF
Bản tin Mitsubishi tháng 1/2012
PDF
Kham pha Pajero Sport bang hinh anh
PDF
Bodas albert camus
Transportation
Age Awareness
c# at f#
Apresentação bizmeet
Disability Discrimination Month
Celebrate Italian, Polish and Native American Heritage in October
Bản tin Mitsubishi tháng 1/2012
Kham pha Pajero Sport bang hinh anh
Bodas albert camus
Ad

Similar to C# AND F# (20)

PPTX
Introduction to C#
DOCX
fds unit1.docx
PDF
C++ Training
PDF
434090527-C-Cheat-Sheet. pdf C# program
PPTX
Notes(1).pptx
PPTX
C language (1).pptxC language (1C language (1).pptx).pptx
PPTX
programming for problem solving in C and C++.pptx
PPTX
c & c++ logic building concepts practice.pptx
PPTX
C Language Presentation.pptx
DOCX
1 CMPS 12M Introduction to Data Structures Lab La.docx
PDF
qb unit2 solve eem201.pdf
PPT
Difference between Java and c#
PPTX
C Language (All Concept)
PPTX
Final requirement
ODP
Ppt of c vs c#
PDF
C notes.pdf
PDF
C programming notes
PDF
CSharpCheatSheetV1.pdf
PPTX
Introduction to c sharp
Introduction to C#
fds unit1.docx
C++ Training
434090527-C-Cheat-Sheet. pdf C# program
Notes(1).pptx
C language (1).pptxC language (1C language (1).pptx).pptx
programming for problem solving in C and C++.pptx
c & c++ logic building concepts practice.pptx
C Language Presentation.pptx
1 CMPS 12M Introduction to Data Structures Lab La.docx
qb unit2 solve eem201.pdf
Difference between Java and c#
C Language (All Concept)
Final requirement
Ppt of c vs c#
C notes.pdf
C programming notes
CSharpCheatSheetV1.pdf
Introduction to c sharp

Recently uploaded (20)

PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Lesson notes of climatology university.
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
01-Introduction-to-Information-Management.pdf
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
O7-L3 Supply Chain Operations - ICLT Program
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
A systematic review of self-coping strategies used by university students to ...
102 student loan defaulters named and shamed – Is someone you know on the list?
Lesson notes of climatology university.
202450812 BayCHI UCSC-SV 20250812 v17.pptx
VCE English Exam - Section C Student Revision Booklet
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Final Presentation General Medicine 03-08-2024.pptx
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
human mycosis Human fungal infections are called human mycosis..pptx
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
FourierSeries-QuestionsWithAnswers(Part-A).pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
01-Introduction-to-Information-Management.pdf
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Final Presentation General Medicine 03-08-2024.pptx
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Abdominal Access Techniques with Prof. Dr. R K Mishra

C# AND F#

  • 2. C SHARPIt was developed by Microsoft within its .NET initiative and later approved as a standard by Ecma (ECMA-334) and ISO (ISO/IEC 23270). C# is one of the programming languages designed for the Common Language Infrastructure."C sharp" was inspired by musical notation where a sharp indicates that the written note should be made a semitone higher in pitch.C#'s principal designer and lead architect at Microsoft is Anders Hejlsberg, who was previously involved with the design of Turbo Pascal, Embarcadero Delphi.
  • 3. Design Goals of C#C# language is intended to be a simple, modern, general-purpose, object-oriented programming language.The language, and implementations thereof, should provide support for software engineering principles such as strong type checking, array bounds checking, detection of attempts to use uninitialized variables, and automatic garbage collection.The language is intended for use in developing software components suitable for deployment in distributed environments.Source code portability is very important, as is programmer portability, especially for those programmers already familiar with C and C++.
  • 4. Design Goals of C#Support for internationalization is very important.C# is intended to be suitable for writing applications for both hosted and embedded systems, ranging from the very large that use sophisticated operating systems, down to the very small having dedicated functions.Although C# applications are intended to be economical with regard to memory and processing power requirements, the language was not intended to compete directly on performance and size with C or assembly language.
  • 6. Distinguishing Features of C#It has no global variables or functions. All methods and members must be declared within classes. Static members of public classes can substitute for global variables and functions.Local variables cannot shadow variables of the enclosing block, unlike C and C++. Variable shadowing is often considered confusing by C++ texts.C# supports a strict Boolean data type.In C#, memory address pointers can only be used within blocks specifically marked as unsafe, and programs with unsafe code need appropriate permissions to run. Managed memory cannot be explicitly freed.
  • 7. Distinguishing Features of C#Multiple inheritance is not supported, although a class can implement any number of interfaces.C# is more type safe than C++. C# currently (as of version 4.0) has 77 reserved words.
  • 8. Categories of data typesValue typesValue types are plain aggregations of data. Instances of value types do not have referential identity nor a referential comparison semantics - equality and inequality comparisons for value types compare the actual data values within the instances, unless the corresponding operators are overloaded.
  • 9. Examples of value types are all primitive types, such as int (a signed 32-bit integer), float (a 32-bit IEEE floating-point number), char (a 16-bit Unicode code unit), and System.DateTime (identifies a specific point in time with nanosecond precision).Categories of data typesReference typesreference types have the notion of referential identity - each instance of a reference type is inherently distinct from every other instance, even if the data within both instances is the same.
  • 10. Examples of reference types are object (the ultimate base class for all other C# classes), System.String (a string of Unicode characters), and System.Array (a base class for all C# arrays).Code commentsC# utilizes a double forward slash (//) to indicate the rest of the line is a comment. This is inherited from C++.public class Foo{ // a comment public static void Bar(intfirstParam) {} // also a comment}Multi-line comments can be indicated by a starting forward slash/asterisk (/*) and ending asterisk/forward slash (*/). This is inherited from standard C.public class Foo{/* A Multi-Line comment */ public static void Bar(intfirstParam) {}}
  • 11. PreprocessorC# features "preprocessor directives" (though it does not have an actual preprocessor) based on the C preprocessor that allow programmers to define symbols but not macros. Conditionals such as #if, #endif, and #else are also provided. Directives such as #region give hints to editors for code folding.public class Foo{#region Procedures public void IntBar(intfirstParam) {} public void StrBar(string firstParam) {} public void BoolBar(bool firstParam) {} #endregion #region Constructors public Foo() {} public Foo(intfirstParam) {} #endregion}
  • 12. "Hello world" exampleusing System;class Program{ static void Main() {Console.WriteLine("Hello world!"); }}
  • 13. using System;The using statement allows the programmer to state all candidate prefixes to use during compilation instead of always using full type names.class ProgramAbove is a class definition. Everything between the following pair of braces describes Program.static void Main()This declares the class member method where the program begins execution. The void keyword declares that Main has no return value.Console.WriteLine("Hello world!");The program calls the Console method WriteLine, which displays on the console a line with the argument, the string "Hello world!".Comparison of C Sharp and JavaBoth languages are considered "curly brace" languages in the C/C++ family. Overall the syntaxes of the languages are very similar.The syntax at the statement and expression level is almost identical with obvious inspiration from the C/C++ tradition.Java is explicit about extending classes and implementing interfaces, while C# infers this from the kind of types a new class/interface derives from.C# supports more features than Java which to some extent is also evident in the syntax which specifies more keywords and more grammar rules than Java.
  • 19. C Sharp IdentifierAn identifier can:start with a "_".
  • 20. contain both upper case and lower case Unicode letters. Case is significant.An identifier cannot:start with a numeral.
  • 21. start with a symbol, unless it is a keyword (check Keywords).
  • 22. have more than 511 chars.C# keywords, reserved words
  • 25. VariablesVariables are identifiers associated with values. They are declared by writing the variable's type and name, and are optionally initialized in the same statement by assigning a value.DeclareintMyInt; // Declaring an uninitialized variable called 'MyInt', of type 'int'InitializeintMyInt; // Declaring an uninitialized variableMyInt = 35; // Initializing the variableDeclare & initializeintMyInt = 35; // Declaring and initializing the variable at the same time
  • 27. Conditional structuresif statementThe if statement is entered when the given condition is true. Single-line case statements do not require block braces although it is mostly preferred by convention.Simple one-line statement:if (i == 3) ... ;Multi-line with else-block (without any braces):if (i == 2) ...else ...
  • 28. Conditional structuresswitch statementThe switch construct serves as a filter for different values. switch (ch){case 'A': ... break; case 'B': case 'C': ... break; default: ... break;}
  • 29. Jump statementsThe goto statement can be used in switch statements to jump from one case to another or to fall through from one case to the next.switch(n){ case 1:Console.WriteLine("Case 1"); break; case 2:Console.WriteLine("Case 2");goto case 1; case 3:Console.WriteLine("Case 3"); case 4: // Compilation will fail here as cases cannot fall through in C#.Console.WriteLine("Case 4");goto default; // This is the correct way to fall through to the next case. default:Console.WriteLine("Default");}
  • 30. Iteration structureswhile loopwhile (i == true){ ...}do ... while loopdo{ ...}while (i == true);for loopThe for loop consists of three parts: declaration, condition and increment. Any of them can be left out as they are optional.for (int i = 0; i < 10; i++){ ...}
  • 31. break statementThe break statement breaks out of the closest loop or switch statement. Execution continues in the statement after the terminated statement, if any.int e = 10;for (int i=0; i < e; i++){ while (true) { break; } // Will break to this point.}
  • 32. continue statementThe continue statement discontinues the current iteration of the current control statement and begins the next iteration.intch;while ((ch = GetChar()) >= 0){ if (ch == ' ') continue; // Skips the rest of the while-loop // Rest of the while-loop ...}
  • 33. ModifiersModifiers are keywords used to modify declarations of types and type members. Most notably there is a sub-group containing the access modifiers.abstract - Specifies that a class only serves as a base class. It must be implemented in an inheriting class.
  • 34. const - Specifies that a variable is a constant value that has to be initialized when it gets declared.
  • 35. event - Declare an event.
  • 36. extern - Specify that a method signature without a body uses a DLL-import.
  • 37. override - Specify that a method or property declaration is an override of a virtual member or an implementation of a member of an abstract class.
  • 38. readonly - Declare a field that can only be assigned values as part of the declaration or in a constructor in the same class.
  • 39. sealed - Specifies that a class cannot be inherited.
  • 40. static - Specifies that a member belongs to the class and not to a specific instance. (see section static)
  • 41. unsafe - Specifies an unsafe context, which allows the use of pointers.
  • 42. virtual - Specifies that a method or property declaration can be overridden by a derived class.
  • 43. volatile - Specifies a field which may be modified by an external process and prevents an optimizing compiler from modifying the use of the field.FSHARPF# is a multi-paradigm programming language, targeting the .NET Framework, that encompasses functional programming as well as imperative and object-oriented programming disciplines.It is a variant of ML and is largely compatible with the OCaml implementation.F# was initially developed by Don Syme at Microsoft Research but is now being developed at Microsoft Developer Division and is being distributed as a fully supported language in the .NET Framework and Visual Studio as part of Visual Studio 2010.F# is a strongly typed language that uses type inference.
  • 44. F SHARPF# uses pattern matching to resolve names into values. It is also used when accessing discriminated unions.F# comes with a Microsoft Visual Studio language service that integrates it with the IDE.All functions in F# are instances of the function type, and are immutable as well.The F# extended type system is implemented as generic .NET types.
  • 45. ExamplesA few small samples follow:(* This is a comment *)(* Sample hello world program *)printfn "Hello World!"
  • 51. Types
  • 58. The EndPresented by:Harry Kim BaloisBSCS 41A