1 / 23

INSTRUCTOR: DR MARCO VALTORTA CSCE 330 C# GROUP MEMBERS: KONSTANTINOS MALEGOS YASSER AL-MUTAIRY CHRIS HESTER UNIVERSITY

INSTRUCTOR: DR MARCO VALTORTA CSCE 330 C# GROUP MEMBERS: KONSTANTINOS MALEGOS YASSER AL-MUTAIRY CHRIS HESTER UNIVERSITY OF SOUTH CAROLINA. THE BIRTH OF C#. C# parents are C++ and JAVA. So, C# contains many C++ features but also adds the object-oriented features from JAVA.

kiral
Download Presentation

INSTRUCTOR: DR MARCO VALTORTA CSCE 330 C# GROUP MEMBERS: KONSTANTINOS MALEGOS YASSER AL-MUTAIRY CHRIS HESTER UNIVERSITY

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. INSTRUCTOR: DR MARCO VALTORTA CSCE 330 C# GROUP MEMBERS: KONSTANTINOS MALEGOS YASSER AL-MUTAIRY CHRIS HESTER UNIVERSITY OF SOUTH CAROLINA

  2. THE BIRTH OF C# • C# parents are C++ and JAVA. So, C# contains many C++ features but also adds the object-oriented features from JAVA. • C# is the a hybrid language developed by Microsoft. In order to understand the basic features of the language, we must compare them with its predecessors.

  3. INTERESTING CONCEPTS • To produce the first component oriented language in the C/C++ family. You can construct components that have properties, methods and events. • To create a language which everything is an object. C# bridges the gap between primitive types and classes by allowing any piece of data to be treated as object.

  4. MICROSOFT.NET • MICROSOFT.NET is the new programming environment introduced by Microsoft. • It is the new way of building and deploying software that leverages standards such as HTTP and XML to make interoperability a reality. • It is not necessary for C# to use this environment but C# was especially design for this environment.

  5. Common Language Runtime • The CLR serves as an execution engine for applications. • Every byte of code that you write for the framework runs in the CLR. • CLR consists of instructions written in CIL(common intermediate language-pseudo-machine language). CIL instructions are just-in-time and compiled into native machine code at run time. • A given method is compiled only once-the first time is called-and thereafter cached in memory so it can be executed again without delay.

  6. COMMON CIL INSTUCTIONS • LDC-Loads a numeric constant onto the stack • LDELEM-Loads an array element onto the stack • NEWARR-Creates a new array • NEWOBJ-Creates a new object • THROW-Throws an exception

  7. COMPILERS • Microsoft provides CIL compilers for Java, C++, Visual Basic, Cobol, Python, Eiffel and Jscript.You can even use the assembler ILASM to write code in CIL. • All of these languages use the same API so you can port an application from Visual Basic and C++ to C#. • Because high level code ultimately compiles to CIL, the framework lets you write a class in one language and use it or derive it from another. That is language independence!!!

  8. C#API • The new .NET framework class library is a library with 7000 types,classes, structs, interfaces, enumerations. The bad news is that is like learning a new operating system. The good news is that that every languages uses the same API so you can easily switch to VB or C++.

  9. SAMPLE NAMESPACES • System: core data types and auxiliary classes. • System.Net: classes that wrap protocols such as HTTP. • System.Web.Services: classes for writing Web Services. • System.Web.UI: core ASP.NET classes • System.Xml: classes for reading and writing XML data.

  10. CONTINUE… • To enable construction of robust and durable software. C# includes garbage collection,structured exception handling and type safety. • It allows the use of pointers through the unsafe mode where performance is the key issue. • Supports web programming through ASP and XML.

  11. CONTINUE… • C# code can be written in any text editor. The only required task is to download the compiler from the Microsoft’s Website. • It is recommended to use the graphical environment Visual Studio.NET. The advantages are that you can incorporate code from other languages like C++ and C and change it into C# code.

  12. EXAMPLES OF USAGE • using System ; • //Import the WinForms Namespace • using System.Windows.Forms ; • //Class Form1 extends class Form from the //System.Windows.Forms namespace • public class Form1 : Form { • //Main Method • public static void Main() { • //Run the Application Application.Run(new Form1()); } }

  13. RESULT

  14. THE HELLO PROGRAM • class HelloWorld{  public static void Main()   {    System.Console.WriteLine("Hello World") ;   } } • Output will be Hello World

  15. WRITE TO A FILE • public class Writetextfile{    public static void Main(string[] args)    {        FileInfo t = new FileInfo(“example.txt");        StreamWriter Tex =t.CreateText();        Tex.WriteLine(“I am writing to the file");                Tex.Write(Tex.NewLine);        Tex.close();    }}

  16. SIMILARITIES AND DIFFERNCES • DECLARING VARIABLES : • C#: int x; int x=3; • C++: int x; int x=3; • Java: int x; int x=3; • ASSIGNMENTS • C#: xvalue=7; • C++: xvalue=7; • Java: xvalue=7;

  17. CONTINUE… • FOR LOOPS • C#: for(int i =1; i<=10; i++) • Console.WriteLine(“ The number is {0}”, i); • C++: for(int i =1; i<=10; i++) • Printf(“%d\n”,i); • JAVA: for(int i =1; i<=10; i++) • System.out.println(“The number is” +i);

  18. C# VERSUS JAVA • C# and Java are both new generation languages descended from a line including C and C++. Each includes advanced features, like garbage collection, which remove some of the low level maintenance tasks from the programmer. In a lot of areas they are syntactically similar. • C# contains more primitive data types than Java , and also allows more extension to the value types. For example, C# supports 'enumerators', types which are limited to a defined set of constant variables and structs, which are user-defined value types.

  19. CONTINUE… • Unlike Java, C# has the useful feature that we can overload various operators. • Like Java, C# gives up on multiple class inheritance in favor of a single inheritance model extended by the multiple inheritance of interfaces. However, polymorphism is handled in a more complicated fashion, with base class methods either 'overriding' or 'hiding' super class methods.

  20. According to Microsoft the top 6 Reasons to Switch to Visual C# from Java are: • FamiliarityVisual C# provides Java developers with a language that is immediately familiar and comfortable to them, regardless of skill level. • Object-based Type SystemVisual C# provides developers with a modern and intuitive object-based type system that negates the need for complex and verbose data marshalling code commonly found in Java applications.

  21. Continue… • Powerful Component-oriented DevelopmentVisual C# provides developers with a powerful component-oriented development language that includes support for properties, indexers, delegates, inheritance, versioning, and attributes, without the need for esoteric or rigid naming patterns and companion classes. • C# allows developers to use Extensible Markup Language (XML) comments to provide useful and customizable source code documentation.

  22. CONTINUE… • Target Any DeviceVisual C# lets developers target powerful desktop computers and a wide variety of handheld and wireless devices today using identical tools and skills. • Leverage the .NET FrameworkVisual C# provides developers with access to the Microsoft .NET Framework, a robust, thread-safe library of collection classes, networking functionality, data access classes, and more.

  23. ANY QUESTIONS?

More Related