Programming with C# and .NET - PowerPoint PPT Presentation

medwin
slide1 l.
Skip this Video
Loading SlideShow in 5 Seconds..
Programming with C# and .NET PowerPoint Presentation
Download Presentation
Programming with C# and .NET

play fullscreen
1 / 181
Download Presentation
Programming with C# and .NET
731 Views
Download Presentation

Programming with C# and .NET

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Programming with C# and .NET

  2. Outline 1 Demo .NET introduction C# Programming 2 3 .NET Remoting 4

  3. Programming with C# and .NET Demo

  4. The Basic Idea • C# is the programming language that I • am long waiting for, because my bad • MFC experience. • Question: How to use C# to do • Image Processing • OpenGL Programming(3D Graphics) • DirectX Programming • SEE DEMO

  5. Programming with C# and .NET .NET

  6. Major Components • CLR • Common Language Runtime • a runtime environment • concept similar to JVM • FCL • Framework Class Library • built on top of the CLR • provide services for modern applications

  7. FCL CLR Windows API Windows Operating System (Windows ME, 98, 2000, XP etc) .NET Framework Overview Applications written in J# .NET, VB .NET, or C#

  8. MSIL • Microsoft Intermediate Language • a CPU independent set of instructions • .NET compliant language compile into MSIL • similar to Java Byte Code • sometimes abbreviated as IL

  9. .NET Visual J# .NET C# VB .NET Compile into MSIL MSIL CLR do this Linux native code Windows native code Mac OS native code Will Support soon Support now Will Support soon

  10. Java Java Java Byte Code JVM do this Linux native code Windows native code Mac OS native code

  11. .NET Compliant Languages • Any language that can be compiled into MSIL is called a .NET compliant language • APL, Pascal, Perl, Python, Scheme, Eiffel, Fortran, Java, Jscript, Haskell, COBAL, RPG, APL, Smalltalk, Component Pascal, Curriculum, Mercury, Oberon, Oz, VB .NET , C#, Visual C++ .NET, Visual J# .NET, …

  12. MSIL Advantages • Portability between OS • .NET compliant language are all compiled into MSIL (portable between OS) and can be further compiled into native OS machine codes by CLR • Language Interoperability • Different languages can communicated easily • MSIL codes from different languages can be linked together to form a program

  13. MSIL MSIL MSIL Interoperability Visual J# .NET C# VB .NET Compile into MSIL linked the MSIL codes CLR generated a single application (native code) Windows native code

  14. Language Interoperability • Rules defined in • Common Type System (CTS) • Common Language Specification (CLS) • Cross-language development • Cross-language Debugging • Cross-language Exception Handling • Cross-language Inheritance

  15. Common Type System (CTS) • To unify the data types • Common data types play an important role in • language interoperability • Types can be of two types • Value Type • Reference Type

  16. .NET vs. Java • Runtime environment • .NET  CLR • Java  JVM • Intermediate Code • .NET  MSIL • Java  Java Byte Code • Support • .NET  Multiple Languages, Multiple Platform • Java  Single Language, Multiple Platform

  17. CLR • Load and execute the C # program • Compile the MSIL into native code • use Just-in-Time (JIT) compilers • Garbage Collection • use Garbage Collector (GC) • Security Management • Exception Handling

  18. Managed vs. Unmanaged Code • Managed Code • executed under the control of CLR, and use • the .NET Framework libraries. • Unmanaged Code • does not execute under the CLR • It is possible for managed and unmanaged • code to work together

  19. FCL • concept similar to MFC for Windows • programming • FCL classes are grouped by namespaces and • exported by assemblies • namespace similar to Java package • assembly similar to .dll

  20. FCL • Some Namespaces in FCL (has hierarchy) • System • System.IO • System.Windows.Forms • System.Drawing • Example: • System.Windows.Forms is located in • System.Windows.Forms.dll

  21. CLR vs. CLI • CLI (Common Language Infrastructure) • CLR vs. CLI • CLI is the rule • CLR is the implementation • your own CLR • You can implement your own CLR according • the CLI

  22. MSIL vs. CIL • CIL (Common Intermediate Language) • MSIL vs. CIL • CIL is the rule • MSIL is the implementation • your own IL • You can implement your own IL according • the CIL

  23. Web Services • ASP .NET • host on IIS server • .NET Remoting • can host on any type of applications

  24. Programming with C# and .NET Windows Programming so easy! C#

  25. Anders Hejlsberg • Creator of • C# • Turbo Pascal • Delphi • Anders studied engineering at the Technical • University of Denmark, previously worked for • Borland, now works for Microsoft.

  26. Special features • Properties • Indexers • Delegates and Events • Operator Overloading • Reflection • Attributes • Formatting • Regular Expression

  27. Pointer • Miscellaneous features • jagged array • foreach loop • Runtime type identification (RTTI) • goto • structure (not the same with C/C++)

  28. Start Programming

  29. 1. Simple Console Program link • Visual Studio .NET IDE introduction • C# program overview • System.Console.WriteLine(…); • Build and Run C# program namespace method class

  30. link 2. Rapid Application Development • RAD like Visual Basic and Borland C++ • Builder • concise syntax as Java • event-driven programming style

  31. 3. Use Assembly link • classes may be compiled into .exe or .dll, • such files are called assemblies and are the • packaging units of C# • An assembly is composed of four sections • manifest • type matadata • program code (in MSIL format) • resources used by the program

  32. Manifest • contain information about the assembly itself • Type matadata • information about the data types used by the • program • Program Code • stored in MSIL format • Resources used by the program • such as .bmp or .jpg files