SlideShare a Scribd company logo
1 of 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]

More Related Content

What's hot

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
 

What's hot (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
 

Viewers also liked

Spyder Advisor Capabilities
Spyder Advisor CapabilitiesSpyder Advisor Capabilities
Spyder Advisor CapabilitiesJeannine Ritter
 
Skema Bm Kertas2 Set3
Skema Bm Kertas2 Set3Skema Bm Kertas2 Set3
Skema Bm Kertas2 Set3Kay Aniza
 
Buzzmedia Octagon Keynote
Buzzmedia Octagon KeynoteBuzzmedia Octagon Keynote
Buzzmedia Octagon KeynoteChris George
 
Skema Bm Kertas2 Set1
Skema Bm Kertas2 Set1Skema Bm Kertas2 Set1
Skema Bm Kertas2 Set1Kay Aniza
 
Bm Kertas1 Set1
Bm Kertas1 Set1Bm Kertas1 Set1
Bm Kertas1 Set1Kay Aniza
 
Action Guide Facebook 1.03.2010
Action Guide   Facebook   1.03.2010Action Guide   Facebook   1.03.2010
Action Guide Facebook 1.03.2010mythicgroup
 
Amplifying Social Impact in a Connected Age
Amplifying Social Impact in a Connected AgeAmplifying Social Impact in a Connected Age
Amplifying Social Impact in a Connected AgeMargaret Stangl
 
Wings™ Brochure Uk
Wings™ Brochure UkWings™ Brochure Uk
Wings™ Brochure Ukshaunlovett
 
Open Vpn – Poor Man’S Vpn Solution
Open Vpn – Poor Man’S Vpn SolutionOpen Vpn – Poor Man’S Vpn Solution
Open Vpn – Poor Man’S Vpn Solutionguest782598d5
 
Where Humanity Cries
Where Humanity CriesWhere Humanity Cries
Where Humanity Criesdiretruth
 
Jarrera eta Ikaskuntza Donostia 2011 1. gaia
Jarrera eta Ikaskuntza Donostia 2011 1. gaiaJarrera eta Ikaskuntza Donostia 2011 1. gaia
Jarrera eta Ikaskuntza Donostia 2011 1. gaiaKirolPsikologia
 
A Historia
A HistoriaA Historia
A Historiacurradbc
 
A Search For Compassion
A Search For CompassionA Search For Compassion
A Search For CompassionMichelle
 
Plazacubiertaweb
PlazacubiertawebPlazacubiertaweb
Plazacubiertawebraqueleta
 
The Brazilian Option
The Brazilian Option The Brazilian Option
The Brazilian Option Mely Lerman
 

Viewers also liked (20)

Spyder Advisor Capabilities
Spyder Advisor CapabilitiesSpyder Advisor Capabilities
Spyder Advisor Capabilities
 
Skema Bm Kertas2 Set3
Skema Bm Kertas2 Set3Skema Bm Kertas2 Set3
Skema Bm Kertas2 Set3
 
Hamlet Moeder
Hamlet MoederHamlet Moeder
Hamlet Moeder
 
Buzzmedia Octagon Keynote
Buzzmedia Octagon KeynoteBuzzmedia Octagon Keynote
Buzzmedia Octagon Keynote
 
Skema Bm Kertas2 Set1
Skema Bm Kertas2 Set1Skema Bm Kertas2 Set1
Skema Bm Kertas2 Set1
 
ADE, Inc. Intro
ADE, Inc. IntroADE, Inc. Intro
ADE, Inc. Intro
 
Bm Kertas1 Set1
Bm Kertas1 Set1Bm Kertas1 Set1
Bm Kertas1 Set1
 
Action Guide Facebook 1.03.2010
Action Guide   Facebook   1.03.2010Action Guide   Facebook   1.03.2010
Action Guide Facebook 1.03.2010
 
Amplifying Social Impact in a Connected Age
Amplifying Social Impact in a Connected AgeAmplifying Social Impact in a Connected Age
Amplifying Social Impact in a Connected Age
 
Wings™ Brochure Uk
Wings™ Brochure UkWings™ Brochure Uk
Wings™ Brochure Uk
 
Open Vpn – Poor Man’S Vpn Solution
Open Vpn – Poor Man’S Vpn SolutionOpen Vpn – Poor Man’S Vpn Solution
Open Vpn – Poor Man’S Vpn Solution
 
Check in dance
Check in danceCheck in dance
Check in dance
 
Where Humanity Cries
Where Humanity CriesWhere Humanity Cries
Where Humanity Cries
 
Holidayfun 1
Holidayfun 1Holidayfun 1
Holidayfun 1
 
Jarrera eta Ikaskuntza Donostia 2011 1. gaia
Jarrera eta Ikaskuntza Donostia 2011 1. gaiaJarrera eta Ikaskuntza Donostia 2011 1. gaia
Jarrera eta Ikaskuntza Donostia 2011 1. gaia
 
A Historia
A HistoriaA Historia
A Historia
 
A Search For Compassion
A Search For CompassionA Search For Compassion
A Search For Compassion
 
Plazacubiertaweb
PlazacubiertawebPlazacubiertaweb
Plazacubiertaweb
 
HELLVILLE FINAL
HELLVILLE FINALHELLVILLE FINAL
HELLVILLE FINAL
 
The Brazilian Option
The Brazilian Option The Brazilian Option
The Brazilian Option
 

Similar to Introduction To Csharp

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
 

Similar to Introduction To Csharp (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
 

Recently uploaded

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
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
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 

Recently uploaded (20)

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
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
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 

Introduction To Csharp

  • 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.