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

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 (13)

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

Nymble blocking misbehaviouring users in anonymizing networks
Nymble blocking misbehaviouring users in anonymizing networksNymble blocking misbehaviouring users in anonymizing networks
Nymble blocking misbehaviouring users in anonymizing networksMuthu Samy
 
Git Workshop : Getting Started
Git Workshop : Getting StartedGit Workshop : Getting Started
Git Workshop : Getting StartedWildan Maulana
 
Ketahanan Pangan #1 : Gerakan Sekolah Menanam Melon
Ketahanan Pangan #1 : Gerakan Sekolah Menanam MelonKetahanan Pangan #1 : Gerakan Sekolah Menanam Melon
Ketahanan Pangan #1 : Gerakan Sekolah Menanam MelonWildan Maulana
 
Dia santa cruz aug 17, 1979
Dia santa cruz aug 17, 1979Dia santa cruz aug 17, 1979
Dia santa cruz aug 17, 1979Clifford Stone
 

Viewers also liked (7)

507 cattail
507 cattail507 cattail
507 cattail
 
Nymble blocking misbehaviouring users in anonymizing networks
Nymble blocking misbehaviouring users in anonymizing networksNymble blocking misbehaviouring users in anonymizing networks
Nymble blocking misbehaviouring users in anonymizing networks
 
Git Workshop : Getting Started
Git Workshop : Getting StartedGit Workshop : Getting Started
Git Workshop : Getting Started
 
Ketahanan Pangan #1 : Gerakan Sekolah Menanam Melon
Ketahanan Pangan #1 : Gerakan Sekolah Menanam MelonKetahanan Pangan #1 : Gerakan Sekolah Menanam Melon
Ketahanan Pangan #1 : Gerakan Sekolah Menanam Melon
 
Modality
ModalityModality
Modality
 
Q3 Kstw 11
Q3 Kstw 11Q3 Kstw 11
Q3 Kstw 11
 
Dia santa cruz aug 17, 1979
Dia santa cruz aug 17, 1979Dia santa cruz aug 17, 1979
Dia santa cruz aug 17, 1979
 

Similar to Introduction to C# programming language features and concepts

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 C# programming language features and concepts (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

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
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
 
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
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
#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
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
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
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
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
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
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
 
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
 

Recently uploaded (20)

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
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
 
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
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
#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
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
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
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
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
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
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
 
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?
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
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...
 
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
 

Introduction to C# programming language features and concepts

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