SlideShare une entreprise Scribd logo
1  sur  41
Introduction to C#  Anders Hejlsberg Distinguished Engineer Developer Division Microsoft Corporation
C# – The Big Ideas ,[object Object],[object Object],[object Object],[object Object]
C# – The Big Ideas A component oriented language ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
C# – The Big Ideas Everything really is an object ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
C# – The Big Ideas Robust and durable software ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
C# – The Big Ideas Preservation of Investment ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Hello World using System; class Hello { static void Main() { Console.WriteLine("Hello world"); } }
C# Program Structure ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
C# Program Structure using System; namespace System.Collections { public class Stack { Entry top; public void Push(object data) { top = new Entry(top, data); } public object Pop() { if (top == null) throw new InvalidOperationException(); object result = top.data; top = top.next; return result; } } }
Type System ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],int i = 123; string s = "Hello world"; 123 i s "Hello world"
Type System ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Predefined Types ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Classes ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Structs ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Classes And Structs class CPoint { int x, y; ... } struct SPoint { int x, y; ... } CPoint cp = new CPoint(10, 20); SPoint sp = new SPoint(10, 20); 10 20 sp cp 10 20 CPoint
Interfaces ,[object Object],[object Object],[object Object],interface IDataBound { void Bind(IDataBinder binder); } class EditBox: Control, IDataBound { void IDataBound.Bind(IDataBinder binder) {...} }
Enums ,[object Object],[object Object],[object Object],[object Object],[object Object],enum Color: byte { Red  = 1, Green = 2, Blue  = 4, Black = 0, White = Red | Green | Blue, }
Delegates ,[object Object],[object Object],[object Object],[object Object],[object Object],delegate void MouseEvent(int x, int y); delegate double Func(double x); Func func = new Func(Math.Sin); double x = func(1.0);
Unified Type System ,[object Object],[object Object],[object Object],Stream MemoryStream FileStream Hashtable double int object
Unified Type System ,[object Object],[object Object],[object Object],[object Object],int i = 123; object o = i; int j = (int)o; 123 i o 123 System.Int32 123 j
Unified Type System ,[object Object],[object Object],[object Object],[object Object],[object Object],string s = string.Format( "Your total was {0} on {1}", total, date); Hashtable t = new Hashtable(); t.Add(0, "zero"); t.Add(1, "one"); t.Add(2, "two");
Component Development ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Properties ,[object Object],[object Object],public class Button: Control { private string caption; public string Caption { get { return caption; } set { caption = value; Repaint(); } } } Button b = new Button(); b.Caption = "OK"; String s = b.Caption;
Indexers ,[object Object],[object Object],public class ListBox: Control { private string[] items; public string this[int index] { get { return items[index]; } set {   items[index] = value; Repaint(); } } } ListBox listBox = new ListBox(); listBox[0] = "hello"; Console.WriteLine(listBox[0]);
Events  Sourcing ,[object Object],[object Object],public delegate void EventHandler(object sender, EventArgs e); public class Button {   public event EventHandler Click; protected void OnClick(EventArgs e) {   if (Click != null) Click(this, e);   } }
Events  Handling ,[object Object],public class MyForm: Form { Button okButton; public MyForm() { okButton = new Button(...); okButton.Caption = "OK"; okButton.Click += new EventHandler(OkButtonClick); } void OkButtonClick(object sender, EventArgs e) { ShowMessage("You pressed the OK button"); } }
Attributes ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Attributes public class OrderProcessor { [WebMethod] public void SubmitOrder(PurchaseOrder order) {...} } [XmlRoot("Order", Namespace="urn:acme.b2b-schema.v1")] public class PurchaseOrder { [XmlElement("shipTo")]  public Address ShipTo; [XmlElement("billTo")]  public Address BillTo; [XmlElement("comment")] public string Comment; [XmlElement("items")]  public Item[] Items; [XmlAttribute("date")]  public DateTime OrderDate; } public class Address {...} public class Item {...}
Attributes ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
XML Comments class XmlElement { /// <summary> ///  Returns the attribute with the given name and ///  namespace</summary> /// <param name=&quot;name&quot;> ///  The name of the attribute</param> /// <param name=&quot;ns&quot;> ///  The namespace of the attribute, or null if ///  the attribute has no namespace</param> /// <return> ///  The attribute value, or null if the attribute ///  does not exist</return> /// <seealso cref=&quot;GetAttr(string)&quot;/> /// public string GetAttr(string name, string ns) { ... } }
Statements And Expressions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],void Foo() { i == 1;  // error }
foreach Statement ,[object Object],[object Object],foreach (Customer c in customers.OrderBy(&quot;name&quot;)) { if (c.Orders.Count != 0) { ... } } public static void Main(string[] args) { foreach (string s in args) Console.WriteLine(s); }
Parameter Arrays ,[object Object],[object Object],void printf(string fmt, params object[] args) { foreach (object x in args) { ... } } printf(&quot;%s %i %i&quot;, str, int1, int2); object[] args = new object[3]; args[0] = str; args[1] = int1; Args[2] = int2; printf(&quot;%s %i %i&quot;, args);
Operator Overloading ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Operator Overloading public struct DBInt { public static readonly DBInt Null = new DBInt();   private int value; private bool defined; public bool IsNull { get { return !defined; } } public static DBInt operator +(DBInt x, DBInt y) {...} public static implicit operator DBInt(int x) {...} public static explicit operator int(DBInt x) {...} } DBInt x = 123; DBInt y = DBInt.Null; DBInt z = x + y;
Versioning ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Versioning class Derived: Base // version 1 { public virtual void Foo() { Console.WriteLine(&quot;Derived.Foo&quot;);  } } class Derived: Base // version 2a { new public virtual void Foo() { Console.WriteLine(&quot;Derived.Foo&quot;);  } } class Derived: Base // version 2b { public override void Foo() { base.Foo(); Console.WriteLine(&quot;Derived.Foo&quot;);  } } class Base // version 1 { } class Base  // version 2  { public virtual void Foo() { Console.WriteLine(&quot;Base.Foo&quot;);  } }
Conditional Compilation ,[object Object],[object Object],[object Object],[object Object],public class Debug { [Conditional(&quot;Debug&quot;)] public static void Assert(bool cond, String s) { if (!cond) { throw new AssertionException(s); } } }
Unsafe Code ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],unsafe void Foo() { char* buf = stackalloc char[256]; for (char* p = buf; p < buf + 256; p++) *p = 0; ... }
Unsafe Code class FileStream: Stream { int handle; public unsafe int Read(byte[] buffer, int index, int count) { int n = 0; fixed (byte* p = buffer) { ReadFile(handle, p + index, count, &n, null); } return n; } [dllimport(&quot;kernel32&quot;, SetLastError=true)] static extern unsafe bool ReadFile(int hFile, void* lpBuffer, int nBytesToRead, int* nBytesRead, Overlapped* lpOverlapped); }
More Information ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Contenu connexe

Tendances

C# / Java Language Comparison
C# / Java Language ComparisonC# / Java Language Comparison
C# / Java Language ComparisonRobert Bachmann
 
Advanced CPP Lecture 1- Summer School 2014 - ACA CSE IITK
Advanced CPP Lecture 1- Summer School 2014 - ACA CSE IITKAdvanced CPP Lecture 1- Summer School 2014 - ACA CSE IITK
Advanced CPP Lecture 1- Summer School 2014 - ACA CSE IITKPankaj Prateek
 
Advanced CPP Lecture 2- Summer School 2014 - ACA CSE IITK
Advanced CPP Lecture 2- Summer School 2014 - ACA CSE IITKAdvanced CPP Lecture 2- Summer School 2014 - ACA CSE IITK
Advanced CPP Lecture 2- Summer School 2014 - ACA CSE IITKPankaj Prateek
 
3.3 programming fundamentals
3.3 programming fundamentals3.3 programming fundamentals
3.3 programming fundamentalsSayed Ahmed
 
Clean code and Code Smells
Clean code and Code SmellsClean code and Code Smells
Clean code and Code SmellsMario Sangiorgio
 
Object oriented programming in C++
Object oriented programming in C++Object oriented programming in C++
Object oriented programming in C++jehan1987
 
C# Variables and Operators
C# Variables and OperatorsC# Variables and Operators
C# Variables and OperatorsSunil OS
 
Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)jeffz
 
Classes and objects1
Classes and objects1Classes and objects1
Classes and objects1Vineeta Garg
 

Tendances (14)

C# / Java Language Comparison
C# / Java Language ComparisonC# / Java Language Comparison
C# / Java Language Comparison
 
Advanced CPP Lecture 1- Summer School 2014 - ACA CSE IITK
Advanced CPP Lecture 1- Summer School 2014 - ACA CSE IITKAdvanced CPP Lecture 1- Summer School 2014 - ACA CSE IITK
Advanced CPP Lecture 1- Summer School 2014 - ACA CSE IITK
 
C#ppt
C#pptC#ppt
C#ppt
 
Advanced CPP Lecture 2- Summer School 2014 - ACA CSE IITK
Advanced CPP Lecture 2- Summer School 2014 - ACA CSE IITKAdvanced CPP Lecture 2- Summer School 2014 - ACA CSE IITK
Advanced CPP Lecture 2- Summer School 2014 - ACA CSE IITK
 
3.3 programming fundamentals
3.3 programming fundamentals3.3 programming fundamentals
3.3 programming fundamentals
 
Clean code
Clean codeClean code
Clean code
 
Functional Programming with C#
Functional Programming with C#Functional Programming with C#
Functional Programming with C#
 
Chapter 2
Chapter 2Chapter 2
Chapter 2
 
Clean code and Code Smells
Clean code and Code SmellsClean code and Code Smells
Clean code and Code Smells
 
Object oriented programming in C++
Object oriented programming in C++Object oriented programming in C++
Object oriented programming in C++
 
C# Variables and Operators
C# Variables and OperatorsC# Variables and Operators
C# Variables and Operators
 
Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)
 
Introduction to c#
Introduction to c#Introduction to c#
Introduction to c#
 
Classes and objects1
Classes and objects1Classes and objects1
Classes and objects1
 

En vedette

雲端筆記本 記憶與行動應用的深度整合
雲端筆記本 記憶與行動應用的深度整合雲端筆記本 記憶與行動應用的深度整合
雲端筆記本 記憶與行動應用的深度整合bunny4776
 
Shale Gas: Market Opportunities and Challenges in the EU and Ukraine
Shale Gas: Market Opportunities and Challenges in the EU and UkraineShale Gas: Market Opportunities and Challenges in the EU and Ukraine
Shale Gas: Market Opportunities and Challenges in the EU and UkraineOleksii Leshchenko
 
Kỷ yếu tốt nghiệp Đại học Hoa Sen 12.2011
Kỷ yếu tốt nghiệp Đại học Hoa Sen 12.2011Kỷ yếu tốt nghiệp Đại học Hoa Sen 12.2011
Kỷ yếu tốt nghiệp Đại học Hoa Sen 12.2011Hoa Sen University
 
Menus OnDemand
Menus OnDemandMenus OnDemand
Menus OnDemandsudderth1
 
Olivia lammers a day in the life
Olivia lammers a day in the lifeOlivia lammers a day in the life
Olivia lammers a day in the lifeolammersp1
 
Andrea Stephania Betancur Granda
Andrea Stephania Betancur GrandaAndrea Stephania Betancur Granda
Andrea Stephania Betancur GrandaAndreea Stephania
 
Commercial Portfolio
Commercial PortfolioCommercial Portfolio
Commercial Portfoliohomekab
 
Wayne pua sm portfolio
Wayne pua sm portfolioWayne pua sm portfolio
Wayne pua sm portfolioWayne Pua
 
Still photo assignment
Still photo assignment Still photo assignment
Still photo assignment StephanieUNCA
 
Harnessing e-Form Print Control
Harnessing e-Form Print ControlHarnessing e-Form Print Control
Harnessing e-Form Print ControlPlus Technologies
 
Top Ruby Gems to Start A Project
Top Ruby Gems to Start A ProjectTop Ruby Gems to Start A Project
Top Ruby Gems to Start A ProjectMichel Pigassou
 
Worksheet Listening
Worksheet ListeningWorksheet Listening
Worksheet Listeningsycindyng
 
I Kiss Your Hand Madame
I Kiss Your Hand MadameI Kiss Your Hand Madame
I Kiss Your Hand MadameMakala (D)
 
Infection control risk assessment
Infection control risk assessmentInfection control risk assessment
Infection control risk assessmentKhusnul Khatimah
 
Digital Partner for your Brand Communication
Digital Partner for your Brand CommunicationDigital Partner for your Brand Communication
Digital Partner for your Brand CommunicationSaurabh Pokharna
 

En vedette (20)

雲端筆記本 記憶與行動應用的深度整合
雲端筆記本 記憶與行動應用的深度整合雲端筆記本 記憶與行動應用的深度整合
雲端筆記本 記憶與行動應用的深度整合
 
Shale Gas: Market Opportunities and Challenges in the EU and Ukraine
Shale Gas: Market Opportunities and Challenges in the EU and UkraineShale Gas: Market Opportunities and Challenges in the EU and Ukraine
Shale Gas: Market Opportunities and Challenges in the EU and Ukraine
 
Kỷ yếu tốt nghiệp Đại học Hoa Sen 12.2011
Kỷ yếu tốt nghiệp Đại học Hoa Sen 12.2011Kỷ yếu tốt nghiệp Đại học Hoa Sen 12.2011
Kỷ yếu tốt nghiệp Đại học Hoa Sen 12.2011
 
Menus OnDemand
Menus OnDemandMenus OnDemand
Menus OnDemand
 
Olivia lammers a day in the life
Olivia lammers a day in the lifeOlivia lammers a day in the life
Olivia lammers a day in the life
 
W h i t e ...
W h i t e ...W h i t e ...
W h i t e ...
 
Andrea Stephania Betancur Granda
Andrea Stephania Betancur GrandaAndrea Stephania Betancur Granda
Andrea Stephania Betancur Granda
 
History
HistoryHistory
History
 
Commercial Portfolio
Commercial PortfolioCommercial Portfolio
Commercial Portfolio
 
Kohus
KohusKohus
Kohus
 
Presentation1 cesm
Presentation1 cesmPresentation1 cesm
Presentation1 cesm
 
Wayne pua sm portfolio
Wayne pua sm portfolioWayne pua sm portfolio
Wayne pua sm portfolio
 
New paper JR
New paper JRNew paper JR
New paper JR
 
Still photo assignment
Still photo assignment Still photo assignment
Still photo assignment
 
Harnessing e-Form Print Control
Harnessing e-Form Print ControlHarnessing e-Form Print Control
Harnessing e-Form Print Control
 
Top Ruby Gems to Start A Project
Top Ruby Gems to Start A ProjectTop Ruby Gems to Start A Project
Top Ruby Gems to Start A Project
 
Worksheet Listening
Worksheet ListeningWorksheet Listening
Worksheet Listening
 
I Kiss Your Hand Madame
I Kiss Your Hand MadameI Kiss Your Hand Madame
I Kiss Your Hand Madame
 
Infection control risk assessment
Infection control risk assessmentInfection control risk assessment
Infection control risk assessment
 
Digital Partner for your Brand Communication
Digital Partner for your Brand CommunicationDigital Partner for your Brand Communication
Digital Partner for your Brand Communication
 

Similaire à Introduction to-csharp-1229579367461426-1

Introduction to-csharp
Introduction to-csharpIntroduction to-csharp
Introduction to-csharpSDFG5
 
Introduction to Csharp (C-Sharp) is a programming language developed by Micro...
Introduction to Csharp (C-Sharp) is a programming language developed by Micro...Introduction to Csharp (C-Sharp) is a programming language developed by Micro...
Introduction to Csharp (C-Sharp) is a programming language developed by Micro...NALESVPMEngg
 
Introduction-to-Csharp.ppt
Introduction-to-Csharp.pptIntroduction-to-Csharp.ppt
Introduction-to-Csharp.pptAlmamoon
 
Introduction-to-Csharp.ppt
Introduction-to-Csharp.pptIntroduction-to-Csharp.ppt
Introduction-to-Csharp.pptmothertheressa
 
IntroToCSharpcode.ppt
IntroToCSharpcode.pptIntroToCSharpcode.ppt
IntroToCSharpcode.pptpsundarau
 
Introduction to c#
Introduction to c#Introduction to c#
Introduction to c#singhadarsh
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharpvoegtu
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharpvoegtu
 
PERTEMUAN 1 - MENGENAL ENVIRONTMENT PROGRAM VISUAL C#.pptx
PERTEMUAN 1 - MENGENAL ENVIRONTMENT PROGRAM VISUAL C#.pptxPERTEMUAN 1 - MENGENAL ENVIRONTMENT PROGRAM VISUAL C#.pptx
PERTEMUAN 1 - MENGENAL ENVIRONTMENT PROGRAM VISUAL C#.pptxTriSandhikaJaya
 
Clean code _v2003
 Clean code _v2003 Clean code _v2003
Clean code _v2003R696
 
devLink - What's New in C# 4?
devLink - What's New in C# 4?devLink - What's New in C# 4?
devLink - What's New in C# 4?Kevin Pilch
 
Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Juan Pablo
 
Embedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for JavaEmbedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for JavaJevgeni Kabanov
 
Attributes & .NET components
Attributes & .NET componentsAttributes & .NET components
Attributes & .NET componentsBình Trọng Án
 
Simulation Tool - Plugin Development
Simulation Tool - Plugin DevelopmentSimulation Tool - Plugin Development
Simulation Tool - Plugin DevelopmentFrank Bergmann
 

Similaire à Introduction to-csharp-1229579367461426-1 (20)

Introduction to-csharp
Introduction to-csharpIntroduction to-csharp
Introduction to-csharp
 
Introduction to Csharp (C-Sharp) is a programming language developed by Micro...
Introduction to Csharp (C-Sharp) is a programming language developed by Micro...Introduction to Csharp (C-Sharp) is a programming language developed by Micro...
Introduction to Csharp (C-Sharp) is a programming language developed by Micro...
 
Introduction-to-Csharp.ppt
Introduction-to-Csharp.pptIntroduction-to-Csharp.ppt
Introduction-to-Csharp.ppt
 
Introduction-to-Csharp.ppt
Introduction-to-Csharp.pptIntroduction-to-Csharp.ppt
Introduction-to-Csharp.ppt
 
IntroToCSharpcode.ppt
IntroToCSharpcode.pptIntroToCSharpcode.ppt
IntroToCSharpcode.ppt
 
Introduction to c#
Introduction to c#Introduction to c#
Introduction to c#
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharp
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharp
 
PERTEMUAN 1 - MENGENAL ENVIRONTMENT PROGRAM VISUAL C#.pptx
PERTEMUAN 1 - MENGENAL ENVIRONTMENT PROGRAM VISUAL C#.pptxPERTEMUAN 1 - MENGENAL ENVIRONTMENT PROGRAM VISUAL C#.pptx
PERTEMUAN 1 - MENGENAL ENVIRONTMENT PROGRAM VISUAL C#.pptx
 
Introduction to c_sharp
Introduction to c_sharpIntroduction to c_sharp
Introduction to c_sharp
 
1204csharp
1204csharp1204csharp
1204csharp
 
Clean code _v2003
 Clean code _v2003 Clean code _v2003
Clean code _v2003
 
devLink - What's New in C# 4?
devLink - What's New in C# 4?devLink - What's New in C# 4?
devLink - What's New in C# 4?
 
OOC MODULE1.pptx
OOC MODULE1.pptxOOC MODULE1.pptx
OOC MODULE1.pptx
 
Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#
 
Embedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for JavaEmbedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for Java
 
Visual Basic 6.0
Visual Basic 6.0Visual Basic 6.0
Visual Basic 6.0
 
Attributes & .NET components
Attributes & .NET componentsAttributes & .NET components
Attributes & .NET components
 
Simulation Tool - Plugin Development
Simulation Tool - Plugin DevelopmentSimulation Tool - Plugin Development
Simulation Tool - Plugin Development
 
C++ theory
C++ theoryC++ theory
C++ theory
 

Dernier

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 

Dernier (20)

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 

Introduction to-csharp-1229579367461426-1

  • 1. Introduction to C# Anders Hejlsberg Distinguished Engineer Developer Division Microsoft Corporation
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7. Hello World using System; class Hello { static void Main() { Console.WriteLine(&quot;Hello world&quot;); } }
  • 8.
  • 9. C# Program Structure using System; namespace System.Collections { public class Stack { Entry top; public void Push(object data) { top = new Entry(top, data); } public object Pop() { if (top == null) throw new InvalidOperationException(); object result = top.data; top = top.next; return result; } } }
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15. Classes And Structs class CPoint { int x, y; ... } struct SPoint { int x, y; ... } CPoint cp = new CPoint(10, 20); SPoint sp = new SPoint(10, 20); 10 20 sp cp 10 20 CPoint
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28. Attributes public class OrderProcessor { [WebMethod] public void SubmitOrder(PurchaseOrder order) {...} } [XmlRoot(&quot;Order&quot;, Namespace=&quot;urn:acme.b2b-schema.v1&quot;)] public class PurchaseOrder { [XmlElement(&quot;shipTo&quot;)] public Address ShipTo; [XmlElement(&quot;billTo&quot;)] public Address BillTo; [XmlElement(&quot;comment&quot;)] public string Comment; [XmlElement(&quot;items&quot;)] public Item[] Items; [XmlAttribute(&quot;date&quot;)] public DateTime OrderDate; } public class Address {...} public class Item {...}
  • 29.
  • 30. XML Comments class XmlElement { /// <summary> /// Returns the attribute with the given name and /// namespace</summary> /// <param name=&quot;name&quot;> /// The name of the attribute</param> /// <param name=&quot;ns&quot;> /// The namespace of the attribute, or null if /// the attribute has no namespace</param> /// <return> /// The attribute value, or null if the attribute /// does not exist</return> /// <seealso cref=&quot;GetAttr(string)&quot;/> /// public string GetAttr(string name, string ns) { ... } }
  • 31.
  • 32.
  • 33.
  • 34.
  • 35. Operator Overloading public struct DBInt { public static readonly DBInt Null = new DBInt(); private int value; private bool defined; public bool IsNull { get { return !defined; } } public static DBInt operator +(DBInt x, DBInt y) {...} public static implicit operator DBInt(int x) {...} public static explicit operator int(DBInt x) {...} } DBInt x = 123; DBInt y = DBInt.Null; DBInt z = x + y;
  • 36.
  • 37. Versioning class Derived: Base // version 1 { public virtual void Foo() { Console.WriteLine(&quot;Derived.Foo&quot;); } } class Derived: Base // version 2a { new public virtual void Foo() { Console.WriteLine(&quot;Derived.Foo&quot;); } } class Derived: Base // version 2b { public override void Foo() { base.Foo(); Console.WriteLine(&quot;Derived.Foo&quot;); } } class Base // version 1 { } class Base // version 2 { public virtual void Foo() { Console.WriteLine(&quot;Base.Foo&quot;); } }
  • 38.
  • 39.
  • 40. Unsafe Code class FileStream: Stream { int handle; public unsafe int Read(byte[] buffer, int index, int count) { int n = 0; fixed (byte* p = buffer) { ReadFile(handle, p + index, count, &n, null); } return n; } [dllimport(&quot;kernel32&quot;, SetLastError=true)] static extern unsafe bool ReadFile(int hFile, void* lpBuffer, int nBytesToRead, int* nBytesRead, Overlapped* lpOverlapped); }
  • 41.