Professional Documents
Culture Documents
Csharp Presentation
Csharp Presentation
Csharp Presentation
Introduction
C# was designed around the .NET platform for
Similarity to C++ Safety and ease of use True OOP structure Interoperability with other languages (instantiate a C++ class in C#) Allowing existing code to be used (ie COM objects, DLLs)
Introduction
What languages influenced its creation?
Visual Basic (Rapid App Dev capabilities) Java (Type-safe Ref Modeling) C++ (Power inherited from C) Smalltalk (true object-oriented structure) along with a number of predecessors
Basic C#
This acts as a container for underlying classes, such as Console, XML parsing
functions
Console.WriteLine(It is called Mario Twins); XmlDocument xmlDoc = new XmlDocument();
5
C# Code Structure
using System; // Include the namespace
public class SampleCode { // Create your first class public static void Main() { // Main declared within the class int x, y; Console.Write(Enter two numbers: ); // Write text x = Convert.ToInt32(Console.ReadLine()); // Convert input to int y = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(The sum is + Sum(x,y)); // Write text & vars } public static int Sum(int a, int b) { return(a + b); } } // End of class
6
C# OOP Structure
OOP structure almost identical to C++ in terms of classes, structs Just like C++, it contains private and public member variables and functions The Main() is placed in one of the classes, and the compiler enters runtime via this function Namespaces can be used to contain classes for organization
Throw in a few more namespaces for an even better time System.Xml.XPath allows a DOM tree to be parsed node by node, and even searched by level of indentation System.Xml.Xsl allows a program to load an .xsl for styling, and then output everything to .xml
9
Questions?
11