Первый слайд презентации: Introduction to C#
Слайд 2: What is.NET?
Runtime Operating System .NET Framework Common Type System Common Language Runtime Building Blocks (e.g. for Services) Services:.NET and COM+ SQL Server BizTalk ... Languages : C#, Visual Basic, etc .NET Applications Enterprise Servers ... Sharepoint ... Web Services
Class Loader MSIL to Native Compilers (JIT) Code Manager Garbage Collector (GC) Security Engine Debug Engine Type Checker Exception Manager Thread Support COM Marshaler Base Class Library Support
Слайд 4: Meaning of CLR
Ouutput age of object using System; namespace ConsoleApplication_Test_Csharp { public class SomeClass { int age; public int GetAge() { age = 22; return age; } } public sealed class Program { public static void Main() { System.Console.Write("My age is "); SomeClass me = new SomeClass(); int myAge; myAge = me.GetAge(); System.Console.WriteLine(myAge); Console.ReadLine(); } } }
Analyze of head (32- or 64-bit) Use MSCorEE.dll ( C:\Windows\System32\MSCorEE.dll for 32 -bit) from MSCorEE.dll initialize CLR, assembly entry point of Main() function of our program static void Main() { System.Console.WriteLine("Hello "); System.Console.WriteLine("Goodbye"); }
Слайд 9: What is the CTS ( Common Type System )?
A set of common types any language that runs in CLR should implement no syntax specified Languages often define aliases supports only single inheritance (unlike C ++) all types are inherited from System.Object (Object - type name, root of all other types, System - namespace) For example CTS defines System.Int32 – 4 byte integer C# defines int as an alias of System.Int32
Слайд 11: What is the CLS?
A specification of language features how methods may be called when constructors are called subset of the types in CTS are allowed For example Code that takes UInt32 in a public method UInt32 is not in the CLS Can mark classes as CLS-compliant not marked is assumed to mean not compliant
Слайд 13: The Class Libraries
The common classes used in many programs like Java Class Library eg. System.Console.WriteLine XML, Networking, Filesystem, Crypto, containers Can inherit from many of these classes Many languages run on.NET framework C#, C++, J#, Visual Basic even have Python (see IronPython)
Слайд 14: Assemblies
Code contained in files called “assemblies” code and metadata .dll as before to run: public static void Main(string[] args) types private: local directory, not accessible by others eg. Wolfram.NETLink shared: well-known location, can be GAC strong names: use crypto for signatures then can add some versioning and trust
Слайд 15: COM vs.NET
Historically, COM provided this integration support for interfaces and interaction given a GUID, lookup the type library dynamically instantiate class do RPC to make calls in many cases Difficult to get right software engineering problems not type safe at all
Слайд 16: ASP.NET and ADO.NET
Use.NET languages in web pages thus can write typesafe code server-side or client-side Sharepoint interactions can log in Use the CLR to access databases in the manner of ODBC provides classes for access
Слайд 17: Windows PowerShell
New shell originally for MS Vista available for WinXP/2k3 native.NET instantiates arbitary.NET classes and accesses them Also can access COM objects Allows better interaction with programs Can it surpass bash and others?
Слайд 18: First C# Program
using System; namespace Test { int a = 137; class Hello { public static void Main(string[] args) { Console.WriteLine(“Hello {0}”, a); } } }
Слайд 19: Constructions of Note
using like import in Java: bring in namespaces namespace disambiguation of names like Internet hierarchical names and Java naming class like in Java single inheritance up to object
Слайд 20: Constructions of Note
Console.Write(Line) Takes a formatted string: “Composite Format” Indexed elements: e.g., {0} can be used multiple times only evaluated once {index [,alignment][:formatting]} also can use as in Java “Test “ + a