SlideShare ist ein Scribd-Unternehmen logo
1 von 48
C# and F# Programming Language
C SHARP It 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 types Value types ,[object Object]
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).,[object Object]
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).,[object Object]
Preprocessor C# 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" example using System; class Program {     static void Main()     { Console.WriteLine("Hello world!");     } }
using System; ,[object Object],class Program ,[object Object],static void Main() ,[object Object],Console.WriteLine("Hello world!"); ,[object Object],[object Object]
Simple/primitive types
Advanced numeric types
Lifted (nullable) types
Special feature keywords
Special feature keywords
C Sharp Identifier An identifier can: ,[object Object]
contain both upper case and lower case Unicode letters. Case is significant.An identifier cannot: ,[object Object]
start with a symbol, unless it is a keyword (check Keywords).
have more than 511 chars.,[object Object]
C Sharp Literals
C Sharp Literals
 Variables Variables 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. Declare intMyInt;         // Declaring an uninitialized variable called 'MyInt', of type 'int' Initialize intMyInt;        // Declaring an uninitialized variable MyInt = 35;       // Initializing the variable Declare & initialize intMyInt = 35;   // Declaring and initializing the variable at the same time
 Operators
Conditional structures if statement ,[object Object],Simple one-line statement: if (i == 3) ... ; Multi-line with else-block (without any braces): if (i == 2)     ... else     ...
Conditional structures switch statement ,[object Object],switch (ch) { case 'A':         ...         break;     case 'B':     case 'C':          ...          break;     default:         ...         break; }
Jump statements The 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 structures while loop while (i == true) {     ... } do ... while loop do {     ... } while (i == true); for loop ,[object Object],for (int i = 0; i < 10; i++) {     ... }
break statement The 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 statement The 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     ... }
Modifiers Modifiers are keywords used to modify declarations of types and type members. Most notably there is a sub-group containing the access modifiers. ,[object Object]
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.,[object Object]
F SHARP F# 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.
Examples A few small samples follow: (* This is a comment *) (* Sample hello world program *) printfn "Hello World!"
 Operators
Operators
Functions

Weitere ähnliche Inhalte

Was ist angesagt?

Top C Language Interview Questions and Answer
Top C Language Interview Questions and AnswerTop C Language Interview Questions and Answer
Top C Language Interview Questions and AnswerVineet Kumar Saini
 
C++ programming language basic to advance level
C++ programming language basic to advance levelC++ programming language basic to advance level
C++ programming language basic to advance levelsajjad ali khan
 
New c sharp4_features_part_ii
New c sharp4_features_part_iiNew c sharp4_features_part_ii
New c sharp4_features_part_iiNico Ludwig
 
Python Interview questions 2020
Python Interview questions 2020Python Interview questions 2020
Python Interview questions 2020VigneshVijay21
 
Language tour of dart
Language tour of dartLanguage tour of dart
Language tour of dartImran Qasim
 
C programming interview questions
C programming interview questionsC programming interview questions
C programming interview questionsadarshynl
 
CSharp difference faqs- 1
CSharp difference faqs- 1CSharp difference faqs- 1
CSharp difference faqs- 1Umar Ali
 
Complete c programming presentation
Complete c programming presentationComplete c programming presentation
Complete c programming presentationnadim akber
 
C# lecture 2: Literals , Variables and Data Types in C#
C# lecture 2: Literals , Variables and Data Types in C#C# lecture 2: Literals , Variables and Data Types in C#
C# lecture 2: Literals , Variables and Data Types in C#Dr.Neeraj Kumar Pandey
 
Javascript by Yahoo
Javascript by YahooJavascript by Yahoo
Javascript by Yahoobirbal
 

Was ist angesagt? (18)

Top C Language Interview Questions and Answer
Top C Language Interview Questions and AnswerTop C Language Interview Questions and Answer
Top C Language Interview Questions and Answer
 
C++ programming language basic to advance level
C++ programming language basic to advance levelC++ programming language basic to advance level
C++ programming language basic to advance level
 
New c sharp4_features_part_ii
New c sharp4_features_part_iiNew c sharp4_features_part_ii
New c sharp4_features_part_ii
 
Python Interview questions 2020
Python Interview questions 2020Python Interview questions 2020
Python Interview questions 2020
 
Language tour of dart
Language tour of dartLanguage tour of dart
Language tour of dart
 
C programming interview questions
C programming interview questionsC programming interview questions
C programming interview questions
 
C# - Part 1
C# - Part 1C# - Part 1
C# - Part 1
 
CSharp difference faqs- 1
CSharp difference faqs- 1CSharp difference faqs- 1
CSharp difference faqs- 1
 
Complete c programming presentation
Complete c programming presentationComplete c programming presentation
Complete c programming presentation
 
C sharp
C sharpC sharp
C sharp
 
Deep C
Deep CDeep C
Deep C
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and looping
 
delphi-interfaces.pdf
delphi-interfaces.pdfdelphi-interfaces.pdf
delphi-interfaces.pdf
 
C# lecture 2: Literals , Variables and Data Types in C#
C# lecture 2: Literals , Variables and Data Types in C#C# lecture 2: Literals , Variables and Data Types in C#
C# lecture 2: Literals , Variables and Data Types in C#
 
88 c-programs
88 c-programs88 c-programs
88 c-programs
 
C reference manual
C reference manualC reference manual
C reference manual
 
Javascript by Yahoo
Javascript by YahooJavascript by Yahoo
Javascript by Yahoo
 
C#unit4
C#unit4C#unit4
C#unit4
 

Andere mochten auch

Andere mochten auch (9)

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

Ähnlich wie C# AND F#

Ähnlich wie C# AND F# (20)

Introduction to C#
Introduction to C#Introduction to C#
Introduction to C#
 
fds unit1.docx
fds unit1.docxfds unit1.docx
fds unit1.docx
 
C++ Training
C++ TrainingC++ Training
C++ Training
 
434090527-C-Cheat-Sheet. pdf C# program
434090527-C-Cheat-Sheet. pdf  C# program434090527-C-Cheat-Sheet. pdf  C# program
434090527-C-Cheat-Sheet. pdf C# program
 
Notes(1).pptx
Notes(1).pptxNotes(1).pptx
Notes(1).pptx
 
C Language Presentation.pptx
C Language Presentation.pptxC Language Presentation.pptx
C Language Presentation.pptx
 
1 CMPS 12M Introduction to Data Structures Lab La.docx
1 CMPS 12M Introduction to Data Structures Lab La.docx1 CMPS 12M Introduction to Data Structures Lab La.docx
1 CMPS 12M Introduction to Data Structures Lab La.docx
 
qb unit2 solve eem201.pdf
qb unit2 solve eem201.pdfqb unit2 solve eem201.pdf
qb unit2 solve eem201.pdf
 
Difference between Java and c#
Difference between Java and c#Difference between Java and c#
Difference between Java and c#
 
java vs C#
java vs C#java vs C#
java vs C#
 
C Language (All Concept)
C Language (All Concept)C Language (All Concept)
C Language (All Concept)
 
Final requirement
Final requirementFinal requirement
Final requirement
 
Ppt of c vs c#
Ppt of c vs c#Ppt of c vs c#
Ppt of c vs c#
 
C notes.pdf
C notes.pdfC notes.pdf
C notes.pdf
 
C programming notes
C programming notesC programming notes
C programming notes
 
CSharpCheatSheetV1.pdf
CSharpCheatSheetV1.pdfCSharpCheatSheetV1.pdf
CSharpCheatSheetV1.pdf
 
Introduction to c sharp
Introduction to c sharpIntroduction to c sharp
Introduction to c sharp
 
Basic Structure Of C++
Basic Structure Of C++Basic Structure Of C++
Basic Structure Of C++
 
C programming notes.pdf
C programming notes.pdfC programming notes.pdf
C programming notes.pdf
 
Introduction of C# BY Adarsh Singh
Introduction of C# BY Adarsh SinghIntroduction of C# BY Adarsh Singh
Introduction of C# BY Adarsh Singh
 

Kürzlich hochgeladen

ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIShubhangi Sonawane
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxNikitaBankoti2
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 

Kürzlich hochgeladen (20)

ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 

C# AND F#

  • 1. C# and F# Programming Language
  • 2. C SHARP It 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.
  • 9.
  • 10.
  • 11. Preprocessor C# 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" example using System; class Program { static void Main() { Console.WriteLine("Hello world!"); } }
  • 13.
  • 19.
  • 20.
  • 21. start with a symbol, unless it is a keyword (check Keywords).
  • 22.
  • 25. Variables Variables 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. Declare intMyInt; // Declaring an uninitialized variable called 'MyInt', of type 'int' Initialize intMyInt; // Declaring an uninitialized variable MyInt = 35; // Initializing the variable Declare & initialize intMyInt = 35; // Declaring and initializing the variable at the same time
  • 27.
  • 28.
  • 29. Jump statements The 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.
  • 31. break statement The 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 statement The 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.
  • 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.
  • 44. F SHARP F# 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. Examples A few small samples follow: (* This is a comment *) (* Sample hello world program *) printfn "Hello World!"
  • 51. Types
  • 58. The End Presented by: Harry Kim Balois BSCS 41A