Submit Search
Upload
C# for C++ Programmers: Key Differences and New Features
•
Download as PPTX, PDF
•
2 likes
•
1,661 views
AI-enhanced title
R
russellgmorley
Follow
A comparison of C# and C++ for C++ programmers.
Read less
Read more
Software
Report
Share
Report
Share
1 of 31
Download now
Recommended
C# for C++ programmers
C# for C++ programmers
Mark Whitaker
C# basics
C# basics
Dinesh kumar
CSharp Presentation
CSharp Presentation
Vishwa Mohan
introduction to c #
introduction to c #
Sireesh K
C# Basics
C# Basics
Sunil OS
Functions in c++
Functions in c++
Rokonuzzaman Rony
Constructor and Destructor in c++
Constructor and Destructor in c++
aleenaguen
2CPP14 - Abstraction
2CPP14 - Abstraction
Michael Heron
Recommended
C# for C++ programmers
C# for C++ programmers
Mark Whitaker
C# basics
C# basics
Dinesh kumar
CSharp Presentation
CSharp Presentation
Vishwa Mohan
introduction to c #
introduction to c #
Sireesh K
C# Basics
C# Basics
Sunil OS
Functions in c++
Functions in c++
Rokonuzzaman Rony
Constructor and Destructor in c++
Constructor and Destructor in c++
aleenaguen
2CPP14 - Abstraction
2CPP14 - Abstraction
Michael Heron
OOP in C++
OOP in C++
ppd1961
Introduction To C#
Introduction To C#
SAMIR BHOGAYTA
Constructor and Destructor
Constructor and Destructor
Kamal Acharya
Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)
Sumant Tambe
Crear una dll en C++ y llamarla con la interfaz C#
Crear una dll en C++ y llamarla con la interfaz C#
Ángel Acaymo M. G.
Constructors and Destructor in C++
Constructors and Destructor in C++
International Institute of Information Technology (I²IT)
Hot C++: Rvalue References And Move Semantics
Hot C++: Rvalue References And Move Semantics
Andrey Upadyshev
C#ppt
C#ppt
Sambasivarao Kurakula
Introduction to c#
Introduction to c#
OpenSource Technologies Pvt. Ltd.
C# in depth
C# in depth
Arnon Axelrod
[143] Modern C++ 무조건 써야 해?
[143] Modern C++ 무조건 써야 해?
NAVER D2
Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function
Kamlesh Makvana
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#
Hawkman Academy
Oops concept on c#
Oops concept on c#
baabtra.com - No. 1 supplier of quality freshers
Jdbc example program with access and MySql
Jdbc example program with access and MySql
kamal kotecha
C++ oop
C++ oop
Sunil OS
Comparison between runtime polymorphism and compile time polymorphism
Comparison between runtime polymorphism and compile time polymorphism
CHAITALIUKE1
Formation C# - Cours 1 - Introduction, premiers pas, concepts
Formation C# - Cours 1 - Introduction, premiers pas, concepts
kemenaran
TDD in C - Recently Used List Kata
TDD in C - Recently Used List Kata
Olve Maudal
Templates in c++
Templates in c++
Mayank Bhatt
Ppt of c++ vs c#
Ppt of c++ vs c#
shubhra chauhan
C# Cheat Sheet
C# Cheat Sheet
GlowTouch
More Related Content
What's hot
OOP in C++
OOP in C++
ppd1961
Introduction To C#
Introduction To C#
SAMIR BHOGAYTA
Constructor and Destructor
Constructor and Destructor
Kamal Acharya
Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)
Sumant Tambe
Crear una dll en C++ y llamarla con la interfaz C#
Crear una dll en C++ y llamarla con la interfaz C#
Ángel Acaymo M. G.
Constructors and Destructor in C++
Constructors and Destructor in C++
International Institute of Information Technology (I²IT)
Hot C++: Rvalue References And Move Semantics
Hot C++: Rvalue References And Move Semantics
Andrey Upadyshev
C#ppt
C#ppt
Sambasivarao Kurakula
Introduction to c#
Introduction to c#
OpenSource Technologies Pvt. Ltd.
C# in depth
C# in depth
Arnon Axelrod
[143] Modern C++ 무조건 써야 해?
[143] Modern C++ 무조건 써야 해?
NAVER D2
Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function
Kamlesh Makvana
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#
Hawkman Academy
Oops concept on c#
Oops concept on c#
baabtra.com - No. 1 supplier of quality freshers
Jdbc example program with access and MySql
Jdbc example program with access and MySql
kamal kotecha
C++ oop
C++ oop
Sunil OS
Comparison between runtime polymorphism and compile time polymorphism
Comparison between runtime polymorphism and compile time polymorphism
CHAITALIUKE1
Formation C# - Cours 1 - Introduction, premiers pas, concepts
Formation C# - Cours 1 - Introduction, premiers pas, concepts
kemenaran
TDD in C - Recently Used List Kata
TDD in C - Recently Used List Kata
Olve Maudal
Templates in c++
Templates in c++
Mayank Bhatt
What's hot
(20)
OOP in C++
OOP in C++
Introduction To C#
Introduction To C#
Constructor and Destructor
Constructor and Destructor
Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)
Crear una dll en C++ y llamarla con la interfaz C#
Crear una dll en C++ y llamarla con la interfaz C#
Constructors and Destructor in C++
Constructors and Destructor in C++
Hot C++: Rvalue References And Move Semantics
Hot C++: Rvalue References And Move Semantics
C#ppt
C#ppt
Introduction to c#
Introduction to c#
C# in depth
C# in depth
[143] Modern C++ 무조건 써야 해?
[143] Modern C++ 무조건 써야 해?
Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#
Oops concept on c#
Oops concept on c#
Jdbc example program with access and MySql
Jdbc example program with access and MySql
C++ oop
C++ oop
Comparison between runtime polymorphism and compile time polymorphism
Comparison between runtime polymorphism and compile time polymorphism
Formation C# - Cours 1 - Introduction, premiers pas, concepts
Formation C# - Cours 1 - Introduction, premiers pas, concepts
TDD in C - Recently Used List Kata
TDD in C - Recently Used List Kata
Templates in c++
Templates in c++
Viewers also liked
Ppt of c++ vs c#
Ppt of c++ vs c#
shubhra chauhan
C# Cheat Sheet
C# Cheat Sheet
GlowTouch
C++ vs C#
C++ vs C#
sudipv
difference between c c++ c#
difference between c c++ c#
Sireesh K
Css cheat-sheet-v3
Css cheat-sheet-v3
Mariaa Maria
C# interview
C# interview
Thomson Reuters
C# Basics Quick Reference Sheet
C# Basics Quick Reference Sheet
FrescatiStory
Abstraction in java
Abstraction in java
sawarkar17
Abstract class and Interface
Abstract class and Interface
Haris Bin Zahid
Java Programming - Abstract Class and Interface
Java Programming - Abstract Class and Interface
Oum Saokosal
Classes And Objects
Classes And Objects
rahulsahay19
C++ classes
C++ classes
imhammadali
Differences between c and c++
Differences between c and c++
starlit electronics
20. Object-Oriented Programming Fundamental Principles
20. Object-Oriented Programming Fundamental Principles
Intro C# Book
8 abstract classes and interfaces
8 abstract classes and interfaces
Tuan Ngo
Chapter 9 Abstract Class
Chapter 9 Abstract Class
OUM SAOKOSAL
Viewers also liked
(16)
Ppt of c++ vs c#
Ppt of c++ vs c#
C# Cheat Sheet
C# Cheat Sheet
C++ vs C#
C++ vs C#
difference between c c++ c#
difference between c c++ c#
Css cheat-sheet-v3
Css cheat-sheet-v3
C# interview
C# interview
C# Basics Quick Reference Sheet
C# Basics Quick Reference Sheet
Abstraction in java
Abstraction in java
Abstract class and Interface
Abstract class and Interface
Java Programming - Abstract Class and Interface
Java Programming - Abstract Class and Interface
Classes And Objects
Classes And Objects
C++ classes
C++ classes
Differences between c and c++
Differences between c and c++
20. Object-Oriented Programming Fundamental Principles
20. Object-Oriented Programming Fundamental Principles
8 abstract classes and interfaces
8 abstract classes and interfaces
Chapter 9 Abstract Class
Chapter 9 Abstract Class
Similar to C# for C++ Programmers: Key Differences and New Features
Get the Gist: .NET
Get the Gist: .NET
russellgmorley
C++ idioms.pptx
C++ idioms.pptx
Janani Anbarasan
Oop concept in c++ by MUhammed Thanveer Melayi
Oop concept in c++ by MUhammed Thanveer Melayi
Muhammed Thanveer M
report
report
Quickoffice Test
Labs_BT_20221017.pptx
Labs_BT_20221017.pptx
ssuserb4d806
Critical software developement
Critical software developement
nedseb
Undefined Behavior and Compiler Optimizations (NDC Oslo 2018)
Undefined Behavior and Compiler Optimizations (NDC Oslo 2018)
Patricia Aas
Effective refactoring
Effective refactoring
Arnon Axelrod
C Programming Tutorial - www.infomtec.com
C Programming Tutorial - www.infomtec.com
M-TEC Computer Education
C basics
C basics
Daniela Da Cruz
Cloud native development without the toil
Cloud native development without the toil
Ambassador Labs
GOTOpia 2/2021 "Cloud Native Development Without the Toil: An Overview of Pra...
GOTOpia 2/2021 "Cloud Native Development Without the Toil: An Overview of Pra...
Daniel Bryant
300 101 Dumps - Implementing Cisco IP Routing
300 101 Dumps - Implementing Cisco IP Routing
Sara Rock
App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...
App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...
Cyber Security Alliance
DEF CON 27 - workshop - RICHARD GOLD - mind the gap
DEF CON 27 - workshop - RICHARD GOLD - mind the gap
Felipe Prado
Whose fault is it? - a review of application tuning problems
Whose fault is it? - a review of application tuning problems
Sage Computing Services
Oops lecture 1
Oops lecture 1
rehan16091997
Automate Your Automation | DrupalCon Vienna
Automate Your Automation | DrupalCon Vienna
Pantheon
JAX London 2021: Jumpstart Your Cloud Native Development: An Overview of Prac...
JAX London 2021: Jumpstart Your Cloud Native Development: An Overview of Prac...
Daniel Bryant
C++
C++
Sunil OS
Similar to C# for C++ Programmers: Key Differences and New Features
(20)
Get the Gist: .NET
Get the Gist: .NET
C++ idioms.pptx
C++ idioms.pptx
Oop concept in c++ by MUhammed Thanveer Melayi
Oop concept in c++ by MUhammed Thanveer Melayi
report
report
Labs_BT_20221017.pptx
Labs_BT_20221017.pptx
Critical software developement
Critical software developement
Undefined Behavior and Compiler Optimizations (NDC Oslo 2018)
Undefined Behavior and Compiler Optimizations (NDC Oslo 2018)
Effective refactoring
Effective refactoring
C Programming Tutorial - www.infomtec.com
C Programming Tutorial - www.infomtec.com
C basics
C basics
Cloud native development without the toil
Cloud native development without the toil
GOTOpia 2/2021 "Cloud Native Development Without the Toil: An Overview of Pra...
GOTOpia 2/2021 "Cloud Native Development Without the Toil: An Overview of Pra...
300 101 Dumps - Implementing Cisco IP Routing
300 101 Dumps - Implementing Cisco IP Routing
App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...
App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...
DEF CON 27 - workshop - RICHARD GOLD - mind the gap
DEF CON 27 - workshop - RICHARD GOLD - mind the gap
Whose fault is it? - a review of application tuning problems
Whose fault is it? - a review of application tuning problems
Oops lecture 1
Oops lecture 1
Automate Your Automation | DrupalCon Vienna
Automate Your Automation | DrupalCon Vienna
JAX London 2021: Jumpstart Your Cloud Native Development: An Overview of Prac...
JAX London 2021: Jumpstart Your Cloud Native Development: An Overview of Prac...
C++
C++
Recently uploaded
Cyber security and its impact on E commerce
Cyber security and its impact on E commerce
manigoyal112
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
Diego Iván Oliveros Acosta
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
OnePlan Solutions
Odoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting Service
Devintelle Consulting Service Pvt Ltd Odoo OpenERP
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
Velvetech LLC
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
umasea
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
Christoph Pohl
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
kalichargn70th171
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Mater
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
Andreas Granig
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
Łukasz Chruściel
MYjobs Presentation Django-based project
MYjobs Presentation Django-based project
AnoyGreter
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
vaddepallysandeep122
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
vyaparkranti
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
andrehoraa
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
Alina Yurenko
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
Philip Schwarz
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
StefanoLambiase
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
smiwainfosol
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Cizo Technology Services
Recently uploaded
(20)
Cyber security and its impact on E commerce
Cyber security and its impact on E commerce
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Odoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting Service
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
MYjobs Presentation Django-based project
MYjobs Presentation Django-based project
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
C# for C++ Programmers: Key Differences and New Features
1.
© 2007 Compass
Point, Inc. 9434 SW 55th Avenue Portland OR 97219 Phone: 503.329.1138 info@compass-point.net www.compass-point.net 1 C# for C++ Programmers
2.
© 2007 Compass
Point, Inc. 9434 SW 55th Avenue Portland OR 97219 Phone: 503.329.1138 info@compass-point.net www.compass-point.net 2 How C# Looks
3.
© 2007 Compass
Point, Inc. 9434 SW 55th Avenue Portland OR 97219 Phone: 503.329.1138 info@compass-point.net www.compass-point.net 3 using genericCar; namespace Toyota; { public class Camry : Car { private static Camry camry; private Brake brake; public void main() { camry = new Camry(); camry.getBrake().ToString(); } public Camry() { this.brake = new Brake(); } public override Brake getBrake() { return this.brake; } } } C# Console Application Project
4.
© 2007 Compass
Point, Inc. 9434 SW 55th Avenue Portland OR 97219 Phone: 503.329.1138 info@compass-point.net www.compass-point.net 4 using System.IO; namespace Toyota { public class Brake { string brakeName; public Brake() { this.brakeName = “Brake 1”; } public override string ToString() { System.Console.Out.Writeln(“I’m ” + this.brakeName); } } } Namespace GenericCar Class Car Public MustOverride Sub getBrake() End Class C# Class Library Project Vb.net Class Library Project
5.
© 2007 Compass
Point, Inc. 9434 SW 55th Avenue Portland OR 97219 Phone: 503.329.1138 info@compass-point.net www.compass-point.net 5 Differences between C# and C++
6.
© 2007 Compass
Point, Inc. 9434 SW 55th Avenue Portland OR 97219 Phone: 503.329.1138 info@compass-point.net www.compass-point.net 6 Pointers • Can be used in C# , but only in code blocks, methods, or classes marked with the unsafe keyword. • Primarily used for accessing Win32 functions that use pointers. class MyClass { unsafe int *pX; unsafe int MethodThatUsesPointers() { //can use pointers } int Method() { unsafe { //can use pointers } } }
7.
© 2007 Compass
Point, Inc. 9434 SW 55th Avenue Portland OR 97219 Phone: 503.329.1138 info@compass-point.net www.compass-point.net 7 References, Classes, and Structs • References – are used in C#, which are effectively opaque pointers that don’t allow the aspects of pointer functionality that can cause bugs. • Classes and structs – are different in C#: – structs are value types, stored on the stack, and cannot inherit, – classes always reference types stored on the managed heap and are always derivatives of System.Object.
8.
© 2007 Compass
Point, Inc. 9434 SW 55th Avenue Portland OR 97219 Phone: 503.329.1138 info@compass-point.net www.compass-point.net 8 Accessing native code • C# code can only access native code through PInvoke. class PInvoke { [DllImport("user32.dll")] public static extern int MessageBoxA( int h, string m, string c, int type); public static int Main() { return MessageBoxA(0, "Hello World!", "My Message Box", 0); } }
9.
© 2007 Compass
Point, Inc. 9434 SW 55th Avenue Portland OR 97219 Phone: 503.329.1138 info@compass-point.net www.compass-point.net 9 Destruction • Destruction – Same syntax as for C++, but don’t need to declare it as virtual and shouldn’t add an access modifier. – C# cannot guarantee when a destructor will be called – called by the garbage collector. – Can force cleanup: System.GC.Collect(); – For deterministic destruction, classes should implement IDisposable.Dispose() – C# supports special syntax that mimics C++ classes that are instantiated on the stack where the destructor is called when it goes out of scope: using (MyClassThatHasDestructor mc = new MyClassThatHasDestructor) { //code that uses mc } // mc.Dispose() implicitly called when leaving block.
10.
© 2007 Compass
Point, Inc. 9434 SW 55th Avenue Portland OR 97219 Phone: 503.329.1138 info@compass-point.net www.compass-point.net 10 Miscellaneous • Binary PE format – C# compiler will only generate managed assemblies – no native code. • Operator Overloading – C# can overload operators, but not as many. Not commonly used. • Preprocessor – C# has preprocessor directives, similar to C++ but far fewer. No separate preprocessor – compiler does preprocessing. – C# doesn’t need #include – no need to declare compiler symbols used in code but not yet defined.
11.
© 2007 Compass
Point, Inc. 9434 SW 55th Avenue Portland OR 97219 Phone: 503.329.1138 info@compass-point.net www.compass-point.net 11 Miscellaneous • C# doesn’t require a semicolon after a class • C# doesn’t support class objects on the stack. • const only at compile time, readonly set once at runtime in constructor. • C# has no function pointers – delegates instead.
12.
© 2007 Compass
Point, Inc. 9434 SW 55th Avenue Portland OR 97219 Phone: 503.329.1138 info@compass-point.net www.compass-point.net 12 C# New Features
13.
© 2007 Compass
Point, Inc. 9434 SW 55th Avenue Portland OR 97219 Phone: 503.329.1138 info@compass-point.net www.compass-point.net 13 Delegates delegate void AnOperation(int x); class AClass { void AMethod(int i) { System.Console.WriteLine(“Number is ” + i.ToString()); } static int Main(string[] args) { AClass aClass = new AClass(); AnOperation anOperation = new AnOperation(AClass.AMethod); anOperation(4); } } stdio console output: Number is 4 – When delegate returns a void, is a ‘multicast’ delegate and can represent more than one method. += and -= can be used to add and remove a method from a multicast delegate.
14.
© 2007 Compass
Point, Inc. 9434 SW 55th Avenue Portland OR 97219 Phone: 503.329.1138 info@compass-point.net www.compass-point.net 14 Events • An event source EventSourceClass declares an event with this special syntax: public delegate void EventClass(obj Sender, EventArgs e); public event EventClass SourceEvent; • Client event handlers must look like this: void MyEventCallback(object sender, EventArgs e) { //handle event } • Client event handlers are added to an event source like this: EventSourceClass.SourceEvent += MyEventCallback; • An event source then invokes the event like this: SourceEvent(this, new EventArgs());
15.
© 2007 Compass
Point, Inc. 9434 SW 55th Avenue Portland OR 97219 Phone: 503.329.1138 info@compass-point.net www.compass-point.net 15 Attributes and Properties • Attributes – meta info that can be accessed at runtime [WebMethod] public ShippingPreference[] GetShippingPreferences(ShoppingCart shoppingCart, CustomerInformation customerInformation) { } • Properties class ContainsProperty { private int age; public int Age { get { return age;} set { age = value;} } }
16.
© 2007 Compass
Point, Inc. 9434 SW 55th Avenue Portland OR 97219 Phone: 503.329.1138 info@compass-point.net www.compass-point.net 16 Exceptions • Exceptions in C# support a finally block: try { //normal execution path } catch (Exception ex) { //execution jumps to here if Exception or derivative //is thrown in try block. } finally { //ALWAYS executes, either after try or catch clause executes. }
17.
© 2007 Compass
Point, Inc. 9434 SW 55th Avenue Portland OR 97219 Phone: 503.329.1138 info@compass-point.net www.compass-point.net 17 Miscellaneous • Interfaces • Threading lock() statement (shortcut for System.Threading.Monitor) • Boxing – Value types are primitives. – Value types can be treated as objects – Even literal types can be treated as objects. string age = 42.ToString(); int i = 20; object o = i;
18.
C++ features unsupported
in C# © 2007 Compass Point, Inc. 9434 SW 55th Avenue Portland OR 97219 Phone: 503.329.1138 info@compass-point.net www.compass-point.net 18 • No templates – generics instead (C++/CLI has both) • No multiple inheritance for base classes.
19.
© 2007 Compass
Point, Inc. 9434 SW 55th Avenue Portland OR 97219 Phone: 503.329.1138 info@compass-point.net www.compass-point.net 19 Configuration
20.
© 2007 Compass
Point, Inc. 9434 SW 55th Avenue Portland OR 97219 Phone: 503.329.1138 info@compass-point.net www.compass-point.net 20 XML File Based • .NET assemblies use XML-based configuration files named ExecutableName.exe.config • Registry is not commonly used for .NET applications.
21.
© 2007 Compass
Point, Inc. 9434 SW 55th Avenue Portland OR 97219 Phone: 503.329.1138 info@compass-point.net www.compass-point.net 21 File Format • ExecutableName.exe.config looks like: <configuration> <system.runtime.remoting> <application> <channels> <channel ref="tcp" port="9091" /> </channels> </application> </system.runtime.remoting> <appSettings> <!-- SERVICE --> <!-- false will cause service to run as console application, true requires installing and running as a Windows service --> <add key = "Service.isService" value = "false" /> <add key = "Service.eventsourcestring" value = "CCLI Service" /> <add key = "Service.servicename" value = "CCLI Service" /> <add key = "ServiceAssemblyName" value = "Framework" /> <add key = "ServiceClassNameConsole" value = "StarPraise.Core.ConsoleBootstrapper" /> <add key = "ServiceClassNameService" value = "StarPraise.Core.ComponentController" /> <add key = "Service.strStarting" value = "Service starting..." /> <add key = "Service.strStopping" value = "Service Stopping..." /> <!-- Configuration to use DefaultLogger - writing straight to file. Only for testing - NOT FOR PRODUCTION USE. --> <add key = "Logger.loggerAssembly" value = "Framework" /> <add key = "Logger.loggerclassname" value = "StarPraise.Core.DefaultLogger" /> … </configuration>
22.
Accessing Configuration Values
© 2007 Compass Point, Inc. 9434 SW 55th Avenue Portland OR 97219 Phone: 503.329.1138 info@compass-point.net www.compass-point.net 22 static protected Logger getInstance() { if (Logger.loggerInstance == null) { try { ObjectHandle obj = Activator.CreateInstance( System.Configuration.ConfigurationManager.AppSettings[Logger.loggerAssembly], System.Configuration.ConfigurationManager.AppSettings[Logger.loggerclassname]); Logger.loggerInstance = (Logger) obj.Unwrap(); Logger.loggerInstance.Start(); } catch (Exception ex) { throw new RuntimeException(ex.ToString(), new ComponentIdentity("Logger"), "getInstance"); } }
23.
© 2007 Compass
Point, Inc. 9434 SW 55th Avenue Portland OR 97219 Phone: 503.329.1138 info@compass-point.net www.compass-point.net 23 Application Types
24.
© 2007 Compass
Point, Inc. 9434 SW 55th Avenue Portland OR 97219 Phone: 503.329.1138 info@compass-point.net www.compass-point.net 24 Types There are five primary application (‘executable’) projects in Visual Studio: • Console Applications • Services • Forms Applications • Web Applications • Web Services
25.
© 2007 Compass
Point, Inc. 9434 SW 55th Avenue Portland OR 97219 Phone: 503.329.1138 info@compass-point.net www.compass-point.net 25 Form Applications • VS.NET creates Main and adds to the form application project. • Windows Message Pump is encapsulated entirely within classes contained in System.Windows. • System.Windows.Forms.Form is type automatically created by VS.NET for forms application projects.
26.
© 2007 Compass
Point, Inc. 9434 SW 55th Avenue Portland OR 97219 Phone: 503.329.1138 info@compass-point.net www.compass-point.net 26 Forms Applications using System; using System.Collections.Generic; using System.Windows.Forms; namespace CompassPoint.ECommerce.OrderProcessingServ ices { static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefa ult(false); Application.Run(new OrderProcessingWebServiceTest()); } } } using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace CompassPoint.ECommerce.OrderProcessingServices { public partial class OrderProcessingWebServiceTest : Form { public OrderProcessingWebServiceTest() { InitializeComponent(); } } }
27.
© 2007 Compass
Point, Inc. 9434 SW 55th Avenue Portland OR 97219 Phone: 503.329.1138 info@compass-point.net www.compass-point.net 27 Web Applications • They are hosted in IIS. • A variety of compile options from compile when accessed to pre-compile including partial compile in the creamy middle! • When webpage.aspx is accessed, – IIS delegates to the ASP.NET runtime which • creates a runtime object model for the page, • Reads the page • Returns all markup to IIS to return to browser except • Embedded runat=server marked code in the page which it runs in the runtime object model environment and returns the resulting markup.
28.
© 2007 Compass
Point, Inc. 9434 SW 55th Avenue Portland OR 97219 Phone: 503.329.1138 info@compass-point.net www.compass-point.net 28 Web Services • When a webservice.asmx is accessed, the same thing happens, but SOAP ‘method’ invocation requests are redirected to methods in the web service marked with a special attribute.
29.
© 2007 Compass
Point, Inc. 9434 SW 55th Avenue Portland OR 97219 Phone: 503.329.1138 info@compass-point.net www.compass-point.net 29 Web Services [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [ToolboxItem(false)] public class OrderProcessingService : System.Web.Services.WebService, IOrderManager { [WebMethod] public ShippingPreference[] GetShippingPreferences(ShoppingCart shoppingCart, CustomerInformation customerInformation) { ….
30.
© 2007 Compass
Point, Inc. 9434 SW 55th Avenue Portland OR 97219 Phone: 503.329.1138 info@compass-point.net www.compass-point.net 30 Web Application and Service Configuration • As for applications, configuration is stored in an XML file. • XML file is of same format as for other types of applications. • For both, the file is named web.config.
31.
© 2007 Compass
Point, Inc. 9434 SW 55th Avenue Portland OR 97219 Phone: 503.329.1138 info@compass-point.net www.compass-point.net 31 Discussion
Download now