Visula C# Programming Lecture 1


Published on

Lecter 1

Published in: Education, Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • ECMA is a standards body – for example Jscript – or “ECMAScript”
  • As an aside…the CLR itself is a COM application – can be hosted (along with any .NET Code) by anything that can host COM.
    CLR does an assembly load, checks with the policy manager, and if granted, loads the class, which will then do JIT…and it’s an iterative process
    The CLR is going to be providing the GC, Exception Handling, Class Initialization, Security, etc.
    JIT can still be done at Install Time to noticeably start up faster.
    -GC can run on the same thread or concurrently – also does memory defrag, also handles finding memory to delete
  • Dave starts talking about GAC
    …config files can be set up to force an exe to use a certain version other than that’s in the assembly.
  • Dave transitions to Barry
  • Visula C# Programming Lecture 1

    1. 1. Visual Programming C# 1
    2. 2. SUN MICROSOFT 2
    3. 3. Microsoft and Sun's Confrontation        It's new it's powerful it solves lots of problems it is threatening to a vast community of Java worshippers, and best (or worst) of all it's from Microsoft. You guessed it right;I am talking about .NET Around 1995, Java was generating the same Strength as is generated by .NET today !. Sun's Java introduced a revolutionary approach of software development Java provided the programmer's with a unique tool that solved their ages long problem of platform independence 3
    4. 4. Microsoft and Sun's Confrontation    Sun addressed industry's needs by coming up with tools like JSP, Servlets, EJB, JMS, JNDI, JNI etc. Sun stuffed these excellent tools under one umbrella - the Java2 Enterprise Edition (J2EE). Microsoft was trying to catch up All this time when Sun was winning our admiration; Microsoft was trying their level best to match up to Sun's tools. But Sun was un-catchable Microsoft answer was Microsoft's Windows DNA (Distributed interNet Applications Architecture ) programming model 4
    5. 5. Microsoft and Sun's Confrontation   With the world depending more and more on the Internet - and Sun's tools becoming the foremost media for the web applications So Microsoft put their best men at work and started calling the project as Next Generation Windows Services (NGWS). 5
    6. 6. What is .NET?   Microsoft defines .NET as “a set of Microsoft software technologies for connecting information, people, systems, and devices“ However, Microsoft .NET is not just another programming language  It’s   a complete new business initiative Mission statement: Access to Information anywhere, anytime Everything evolves around the Internet 6
    7. 7. The .NET Framework objectives of The .NET Framework       To provide a consistent object-oriented programming environment whether object code is stored and executed locally, executed locally but Internet-distributed, or executed remotely. To provide a code-execution environment that minimizes software deployment and versioning conflicts. To provide a code-execution environment that guarantees safe execution of code, including code created by an unknown or semi-trusted third party. To provide a code-execution environment that eliminates the performance problems of scripted or interpreted environments. To make the developer experience consistent across widely varying types of applications, such as Windows-based applications and Web-based applications. To build all communication on industry standards to ensure that code based on the .NET Framework can integrate with 7 any other code.
    8. 8. Information Anywhere, Anytime ■ Server machines that provide information or services (database server, content provider,…) 8
    9. 9. Information Anywhere, Anytime ■ Sophisticated computing devices that communicate with PCs to allow access to information 9
    10. 10. Information Anywhere, Anytime ■ A standardized protocol for the internet to allow different programs and devices to talk to each other 10
    11. 11. Information Anywhere, Anytime ■ A set of developer tools that allows you to write server and client programs as well as XML Web Services 11
    12. 12. Personal Opinion New programming languages new virtual machine simply a great IDE 12
    13. 13. Conventional Developing Source Code Source Code Binary code In the past, compiled code only runs on the computer it was compiled for Binary code Operating System Operating System 13
    14. 14. Virtual Machine Concept Source Code Intermediate code Intermediate code Virtual Machine Virtual Machine Operating System Operating System Virtual Machine acting as the adaptor to the physical computer Compiled code will run on any computer as long as this virtual machine is installed 14
    15. 15. .NET Framework Microsoft Intermediate Language (MSIL) .NET Framework / Common Language Runtime (CLR) Operating System Virtual Machine is called “Common Language Runtime” (CLR) or sometimes simply .NET Framework Compiled code also called “Microsoft Intermediate Language” (MSIL) 15
    16. 16. .NET Framework C# VB.NET MSIL J# Many .NET languages C#, VB.NET J# C++ .NET Cobol, Perl ... 16
    17. 17. .Net Languages     Unlike Java’s VM, different languages can be used to compile into Intermediate Language. C# - more like Java than C++ VB.NET – Visual Basic’s response J#, Cobol, Fortran, Scheme, Perl, ... 17
    18. 18. Installing the .NET Framework    .NET Framework installs only on Windows 98 and above It’s a 20 MB file named “dotnetfx.exe” Can also be found   Comes pre-installed starting with Windows Server 2003 18
    19. 19. .NET Framework Class Library  There are literally thousands of extremely useful classes that cover very common tasks:  File operations, networking, cryptography  Database access, Windows-related tasks  One major key to .NET programming is actually to know the classes (instead of wasting time writing them from scratch) 19
    20. 20. Namespaces  Every class belongs to a namespace  e.x., FileInfo belongs to the System.IO namespace  You can refer to it using System.IO.FileInfo or use the “using” or “imports” keyword to “import” entire namespaces  This allows different classes with the same name to co-exist 20
    21. 21. What is "Common Type System" (CTS)      provide language interoperability language sharing the same data types int should mean the same in VB, VC++, C# and all other CTS, much like Java, defines every data type as a Class Every .NET compliant language must stick to this definition 21
    22. 22. Popular Project Types        Console applications. Scripted or hosted applications. Windows GUI applications (Windows Forms). ASP.NET applications. XML Web services. Windows services. Windows Forms Application   ASP.NET Applications   .NET programs that run under the Microsoft Windows platform (previously known as “Win32 Applications”) An entire website that is driven by Microsoft .NET Smart Clients  Sophisticated computing devices that communicate with PCs to allow access to information  PDAs, Laptops, Terminals, Cellphones 22
    23. 23. .NET Development VB C++ C# J# … Common Language Specification ASP.NET Web Forms Web Services Mobile Internet Toolkit Windows Forms ADO.NET and XML Base Class Library Common Language Runtime Operating System 23
    24. 24. The .NET Framework: Common Language Specification  Basic themes of .NET is unification and interoperability between various programming languages  To achieve this there must be some rules followed by all the languages  CLS is the collection of the rules and constraints that every language (that seeks to achieve .NET compatibility) must follow 24
    25. 25. The .NET Framework: Common Language Specification   Microsoft have defined three level of CLS compatibility/compliance. COMPLIANT PRODUCER   CONSUMER   The language in this category can use classes produced in any other language EXTENDER   The component developed in this type of language can be used by any other language Languages in this category can not just use the classes as in CONSUMER category; but can also extend classes using inheritance Microsoft is providing   Visual Basic®, C++, C#, J#, JScript® Industry and academia  APL, COBOL, Eiffel, Fortran, Haskell, ML, Perl, Python, RPG, Scheme, Smalltalk, … 25
    26. 26. Common Language Infrastructure The following organizations have participated and their contributions are gratefully acknowledged: Fujitsu Software, Hewlett-Packard, Intel Corporation, International Business Machines, ISE, Microsoft Corporation, Monash University, Netscape, OpenWave, Plum Hall, Sun Microsystems 26
    27. 27. .NET Development VB C++ C# J# … Common Language Specification ASP.NET Web Forms Web Services Mobile Internet Toolkit Windows Forms ADO.NET and XML Base Class Library Common Language Runtime Operating System 27
    28. 28. Common Language Runtime: Execution model Source code C# C++ Compiler Managed code VB Compiler Compiler Assembly IL Code Assembly IL Code Assembly IL Code Unmanaged Component Common Language Runtime JIT Compiler Native Code Operating System Services 28
    29. 29. What is "Microsoft Intermediate Language" (MSIL)     A .NET programming language (C#, VB.NET, J# etc.) does not compile into executable code compiles into an intermediate code called Microsoft Intermediate Language (MSIL). The MSIL code is then send to the CLR (Common Language Runtime) that converts the code to machine language which is then run on the host machine MSIL is similar to Java Byte code 29
    30. 30. Common Language Runtime      Every .NET Framework application relies on the CLR Every .NET Framework assembly contains a manifest:  Class/Method Meta-Data  Versioning Information The common language runtime manages memory, thread execution, code execution, code safety verification, compilation, and other system services The runtime is designed to enhance performance The runtime also accelerates developer productivity 30
    31. 31. Inside a .NET Framework Application   During Execution, MSIL is JIT Compiled Method-by-Method, and stored in the Global Assembly Cache (machine-wide code cache ) on the Hard Drive The GAC knows the version information!  Copy a new version, execute – and both versions are still available in the cache. App1.exe Ref: Widget.dll, ver App2.exe Ref: Widget.dll, ver Widget.dll Ver GAC Widget.dll Ver 31
    32. 32. .NET Development VB C++ C# J# … Common Language Specification ASP.NET Web Forms Web Services Mobile Internet Toolkit Windows Forms ADO.NET and XML Base Class Library Common Language Runtime Operating System 32
    33. 33. Start Visual Studio.Net 2005 Click on New Project Button 33
    34. 34. . Starting Projects   Creating a New Project In the Visual Studio.NET environment, select File | New | Project from the menu. 34
    35. 35. • • • • • • In left window, select “Visual Basic Projects”. In right window, select “Console Application” Name it What u want (Note: No Spaces!) Click “Browse” button to select your Location. Note location where project will be saved. Click “OK” button to create the project. 35
    36. 36. using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Console.WriteLine ("This is first Program"); Console.ReadLine(); } } } 36
    37. 37. Console Output Note the console window. 37 Press enter to exit that window.