Introduction to the.NET Framework and C# NETbuilder - March 2009 Louis Botterill.

Slides:



Advertisements
Similar presentations
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 12 Introduction to ASP.NET.
Advertisements

.NET Framework Overview
.NET Framework Overview Pingping Ma Nov 16 th, 2006.
.NET Technology.
Introduction to C# Tom Roeder CS fa. Goals of the course Introduce C# language ECMA standard originally developed by MSR not just Java + C++ many.
C#.NET C# language. C# A modern, general-purpose object-oriented language Part of the.NET family of languages ECMA standard Based on C and C++
Introduction to the C# Programming Language for the VB Programmer.
History  We first begin with Java which was released in 1995 by Sun Microsystems  Initially Java was 100% interpreted at runtime and was very slow 
C#: Project Cool Arthur Ketchel II Keith Francisco Chris McInnis.
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
Creating and Running Your First C# Program Svetlin Nakov Telerik Corporation
Tahir Nawaz Visual Programming C# Week 2. What is C#? C# (pronounced "C sharp") is an object- oriented language that is used to build applications for.
.NET framework’s Versions .NET Framework Version Microsoft started development on the.NET Framework in the late 1990s originally under the name of Next.
Platforms and tools for Web Services and Mobile Applications Introduction to C# Bent Thomsen Aalborg University 3rd and 4th of June 2004.
Intro to dot Net Dr. John Abraham UTPA – Fall 09 CSCI 3327.
Differences between C# and C++ Dr. Catherine Stringfellow Dr. Stewart Carpenter.
Creating and Running Your First C# Program Telerik Software Academy Telerik School Academy.
CSCI 3327 Visual Basic Chapter 1: Introduction to Visual Basic
1 Introduction to.NET Framework. 2.NETFramework Internet COM+ Orchestration Orchestration Windows.NET Enterprise ServersBuildingBlockServices Visual Studio.NET.
Introduction to .Net Framework
Eric Vogel Software Developer A.J. Boggs & Company.
Session 1 - Introduction and Data Access Layer
C# A 1 CSC 298 Introduction to C#. C# A 2 What to expect in this class  Background: knowledge of an object oriented language of the C++, Java, … family.
11 Getting Started with C# Chapter Objectives You will be able to: 1. Say in general terms how C# differs from C. 2. Create, compile, and run a.
Microsoft Visual Basic 2005: Reloaded Second Edition
Creating and Running Your First C# Program Svetlin Nakov Telerik Corporation
ASP.NET  ASP.NET is a web development platform, which provides a programming model, a comprehensive software infrastructure and various services required.
BIM313 – Advanced Programming Techniques Object-Oriented Programming 1.
Introduction .NET Framework
C# Programming Fundamentals of Object-Oriented Programming Fundamentals of Object-Oriented Programming Introducing Microsoft.NET Introducing Microsoft.NET.
Distributed Systems (236351) Tutorial 1 - Getting Started with Visual Studio C#.NET.
.NET Framework Danish Sami UG Lead.NetFoundry
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Application Foundation Presented By : Naveed Sattar Software Engineer.
C# Classes and Inheritance CNS 3260 C#.NET Software Development.
PRIOR TO WEB SERVICES THE OTHER TECHNOLOGIES ARE:.
Bill Campbell, UMB Microsoft's.NET C# and The Common Language Runtime.
Object Oriented Software Development 4. C# data types, objects and references.
Introduction to C# Anders Hejlsberg Distinguished Engineer Developer Division Microsoft Corporation.
Text Introduction to.NET Framework. CONFIDENTIAL Agenda .NET Training – Purpose  What is.NET?  Why.NET?  Advantages  Architecture  Components: CLR,
Overview CNS 3260 C#.NET Software Development. 2.NET Framework Began in 2000 Developed in three years (2000 to 2003) Operating System Hardware.NET Framework.
Java and C# - Some Commonalities Compile into machine-independent, language- independent code which runs in a managed execution environment Garbage Collection.
INTRODUCTION BEGINNING C#. C# AND THE.NET RUNTIME AND LIBRARIES The C# compiler compiles and convert C# programs. NET Common Language Runtime (CLR) executes.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
C# Diline Giriş.
Introducing the Microsoft® .NET Framework
Konstantinos pantos Software solutions architect Techaholics
Jim Fawcett CSE681 – SW Modeling & Analysis Fall 2014
.NET Framework 2.0 .NET Framework 3.0 .NET Framework 3.5
CIS 200 Test 01 Review.
.Net A brief introduction to
Introduction to .NET Framework Ch2 – Deitel’s Book
Microsoft .NET 3. Language Innovations Pan Wuming 2017.
Application Foundation
.NET and .NET Core 2. .NET Runtimes Pan Wuming 2017.
CS360 Windows Programming
Introduction to C# AKEEL AHMED.
Tutorial C#.
.NET and .NET Core 5.2 Type Operations Pan Wuming 2016.
Programming in C# CHAPTER 1
Lecture 1 Making a C# GUI Program
Keith Mulkey Senior Software Engineer SFA, Inc.
Java Programming Language
.NET Overview Yingcai Xiao.
ASP.NET
Pointers C#, pointers can only be declared to hold the memory addresses of value types int i = 5; int *p; p = &i; *p = 10; // changes the value of i to.
.Net Framework Details Imran Rashid CTO at ManiWeber Technologies.
Quiz Points 1 Rules Raise your hand if you know the question
.NET Base Type (CTS Data Type) Managed Extensions for C++ Keyword
Paul Stubbs MCSD, MCSE 4.0, MCP+I, MCT, MCAD .Net
Jim Fawcett CSE681 – SW Modeling & Analysis Fall 2018
Presentation transcript:

Introduction to the.NET Framework and C# NETbuilder - March 2009 Louis Botterill

2 Agenda ● The.NET Framework and C# - an introduction – Origins and time-line – Versions and platform variants –.NET high level features – C# overview – C# examples and language features – Tools and GUI builder (quick demo) – Future – Resources and further reading

3 (Not covered in this presentation) ● Other languages, VB etc ● Server side programming ASP.NET ● WCF, WPF ● Silverlight, XAML and XBAP ● LINQ, LINQ to SQL, LINQ to XML etc ● Functional Programming ● ClickOnce etc ● * Can be covered in further presentations...

4 Origins ● From Microsoft, described as a “Software Framework” ● Microsoft started development on the.NET Framework in the late 1990s originally under the name of Next Generation Windows Services (NGWS). By late 2000 the first beta versions of.NET 1.0 were released ● The first release of the.NET Framework was on 13 February 2002

5 Versions Version Version Number Release Date Visual Studio Windows Version VS.NET VS.NET 2003 Server VS Vista, Server VS 2008 Windows 7

6.NET Framework / CLR.NETCLR ? TBA

7 Main variants ●.NET CLR – Desktop applications ●.NET CF – Mobile Applications ● ASP.NET – Server (web) applications

8 Overview features ● Virtual machine based ● Multi-platform (various Microsoft platforms) ● Multiple language support ● VM Garbage collection ● Byte-code is always compiled before execution, either Just In Time (JIT) or in advance of execution using the ngen.exe utility.

9 Language Support (Official) ● C# ● VB (Visual Basic) ● XAML ● JScript ● Powershell

10 Language support (Unofficial) ● IronPython ● IronRuby ● Boo ● IronLisp ● M ● Oxygene ● Nemerle ● Phalanger ● F# And others...

11 Some Basic terminology ● ASP – Active Server Pages ● CIL – Common Intermediate Language (formerly MSIL) ● CLI – Common Language Infrastructure ● CLR – common language runtime ● LINQ – Language Integrated Query ● WCF – Windows Communication Foundation ● WF – Windows workflow Foundation ● WPF – Windows Presentation Foundation ● XAML - Extensible Application Markup Language ● XBAP – XAML Browser APlication

12 Framework Stack

13 Some Key concepts ● Assemblies – are packages of code ● Managed code - is computer program code that executes under the management of a virtual machine, unlike unmanaged code, which is executed directly by the computer's CPU. ● Debug and release builds

14 Assemblies In the Microsoft.NET framework, an assembly is a partially compiled code library for use in deployment, versioning and security. ● In the Microsoft Windows implementation of.NET, an assembly is a PE (portable executable) file for Windows GUI on Intel x86. There are two types: – process assemblies (EXE) – library assemblies (DLL) ● A process assembly represents a process which will use classes defined in library assemblies.

15 The Garbage Collector ● The.NET Garbage Collector (GC) is a non- deterministic, compacting, mark-and-sweep garbage collector. ● The GC runs only when a certain amount of memory has been used or there is enough pressure for memory on the system.

16 Language - C# ● C# (pronounced C Sharp) is a multi-paradigm programming language that encompasses functional, imperative, generic, object-oriented (class-based), and component-oriented programming disciplines. ● It was developed by Microsoft as part of the.NET initiative and later approved as a standard by ECMA (ECMA-334) and ISO (ISO/IEC 23270). C# is one of the programming languages supported by the.NET Framework's Common Language Runtime. ● Designed to be “Very Easy To Learn!”

17 Key Language Features ● Object orientated & Component orientated ● Imperative, Generic ● Bounds checking ● Run time type information ● Pass by value and Pass by reference ● Functions as first class objects ● Pre-processor support

18 Key Language Features (2) ● Strings are immutable ● Single inheritance for classes ● Multiple inheritance for interfaces ● Namespaces – like Java Packages (but much more flexible) ● C# Requires “definite assignment”

19 Ubiquitous Hello World! class Program { static void Main(string[] args) { System.Console.WriteLine(“Hello World!”); } ● Main - entry point, has two overloads Main() and Main(string[]) ● System namespace includes many common objects ● Arrays indexed using []

20 Hello World! v2 using System; namespace ConsoleApp { class Program { static void Main(string[] args) { Console.WriteLine(“Hello ” + args[0]); Console.ReadKey(); } ● using – bring a namespace into scope ● namespace – define a named scope for a block

21 The System namespace ● System – contains.NET types, Garbarge collector, Environment, Console ● System.Collections & System.Collections.Generic - collection classes ● System.Linq – Language Integrated Query ● System.Text – Encoders and decoders,.Regex, StringBuilder etc ● System.IO – File and Directory access, Readers and Writers ● System.Net – HTTP, FTP, sockets etc ● System.Threading – Thread related stuff

22 Numeric types Type SizeSigned byte8no ushort 16no uint32no ulong 64no sbyte8yes short16yes int32yes long64yes float 32yes double 64yes decimal 128yes

23 Type aliases ● Primitive types have keyword aliases, e.g. – string alias for System.String – int alias for System.Int32 – And so on...

24 Foreach using System; class Foreach { static void Main(string[] args) { foreach (string arg in args) { Console.WriteLine(arg); }

25 Properties class MyClass { private int x; public int X { get { return x; } set { if (x < 100) { x = value; } else { throw new ArgumentOutOfRange("x"); } public int Y { get; set; }; }

26 Indexers (indexed properties) public class MyList { private string[] items; public string this[int index] { set { return items[index]; } set { items[index] = value; }

27 Checked Integer arithmetic using System; class Overflow { static void Main() { try { int x = int.MaxValue + 1; // wraps to int.MinValue int y = checked(int.MaxValue + 1); // throws } catch (OverflowException caught) { Console.WriteLine(caught); }

28 Value types //enumeration types enum Suit { Hearts, Clubs, Diamonds, Spades } // structure types struct Rectangle { int x1, y1, x2, y2; } ● struct – no inheritance! ● struct members are private by default ● struct can have constructors ● struct can have static methods and fields ● readonly and const keywords Primitive types, enums, structs

29 Nullable types Provides support for nullable value types ● Example – Nullable ● The syntax T? is shorthand for System.Nullable ●.GetValueOrDefault(); returns value or default value for type ● Use the.HasValue and.Value read-only properties to test for null and retrieve the value ● The Value property returns a value if one is assigned, otherwise a System.InvalidOperationException is thrown ● Use the ?? operator to assign a default value that will be applied when a nullable type whose current value is null is assigned to a non-nullable type, for example int? x = null; int y = x ?? -1;

30 Enumerations (Enums) ● Value objects ● Strongly typed ● Can specific underlying types and values enum DayOfWeek : int { Monday = 1, Tuesday = 2, Wednesday = 4, Thursday = 8, Friday = 16, Saturday = 32. Sunday = 64 Weekend = Saturday | Sunday }

31 Reference types ● Class class Foo: Bar, IFoo {...} ● Interface interface IFoo: IBar {...} ● Arrays string[] strings = new string[10]; ● Delegates delegate void SomeDelegate(); ● Can all be Null!

32 Case statements ● No default fall-through ● Fall through Only on empty cases ● Can switch on non-numeric types i.e. string ● Use of Goto (yes really!) can be used to mimic case fall-through if necessary

33 Some (more unusual) Keywords ● sealed – like Java final, a class cannot be sub- classed ● partial – a class is defined across multiple files/blocks. ● static – can have static classes

34 Inheritance – virtual, override and new ● In a superclass, if a method is not polymorphic, then in its subclasses use the keyword new to provide a new definition that hides the original. ● In a superclass, if a method is polymorphic, use the keyword virtual. In its subclasses, use the keyword override to provide a new polymorphic overridden version. ● * Virtual methods must be explicitly overridden *

35 Example constructor syntax public class MyClass { public MyClass() {.... } public MyClass(int x) : this() {... } public MyClass(int x, int y) : this(x) {.... }

36 Example inheritance syntax public class MyClass : MyBaseClass, IMyInterface, IMyOtherInterface { public MyClass(int someValue) : base(someValue) {... }

37 Destructors public class MyClass : MyOtherClass { ~MyClass() { Do some cleanup...; } ● Destructor as per constructor but with ~ prefix, i.e. name same as class with no return ● Converted into protected Finalize override ● User never calls Finalize

38 Delegates namespace System { public delegate void EventHandler(object sender, EventArgs sent);... } namespace System.Windows.Forms { public class Button {... public event EventHandler Click; } using System.Windows.Forms; class MyForm : Form {... private void initializeComponent() {... okButton = new Button("OK"); okButton.Click += new EventHandler(this.okClick); // create + attach } private void okClick(object sender, EventArgs sent) {... }... private Button okButton; }

39 Actions and Functions ● Declaire a routine with no return Action myFunc = (int v1, string s) => { // Do some stuff... }; ● Declaire a function with a return var createForm = new Func (() => { MyLovelyForm myForm = new MyLovelyForm(); return myForm; });

40 Attributes ● Can be attached to types and members ● Consumed at run-time using reflection ● Based on a class that inherits from Attribute public abstract class ServiceResponseBase { [XmlElement(ElementName = "result", Namespace = " public abstract ServiceResponseElement Result { get; set; } [XmlElement(ElementName = "tss", Namespace = " public abstract TssElement TssElement { get; set; } }

41 Preprocessor directives ● #define, #undef ● #if, #elif ● #else, #endif ● #region some region name ● … code... ● #endregion

42 Tools and plug-ins ● Visual Studio (Pro) 2008 ● Visual Studio Express Edition 2008 SP1 ● Resharper (JetBrains) – Powerful, but not that cheap. Trials available, we don't currently have any licenses. ● DevExpress – – tools and component libraries, Refactor and CodeRush etc ● Whole list of plug-ins on Wikipedia –

43 Tools and plug-ins (2) ● TestDriven.net – Nunit integration ● VisualSVN – Tortoise SVN integration

44 Demo: Time to make a quick GUI ● Show the tools in action ● GUI builder ● Editing properties and events ● Adding event handlers ● Running and debugging

45 The future,.NET 4.0 ● Enhanced parallel computing - multi-core and distributed support ● IronPython and IronRuby support ● F# support ● Microsoft announced the.NET Framework 4.0 on September 29, While full details about its feature set have yet to be released, some general information regarding the company's plans have been made public. Some focus of this release are: ● * Improve support for parallel computing, which target multi-core or distributed systems. To this end, they plan to include technologies like PLINQ (Parallel LINQ), a parallel implementation of the LINQ engine, and Task Parallel Library, which exposes parallel constructs via method calls. ● * Full support for IronPython, IronRuby, and F#. ● * Support for a subset of the.NET Framework and ASP.NET with the "Server Core" variant of Windows Server 2008 R2

46.NET 4.0 ● Expected in 2010 (with Visual studio 2010) – Enhanced COM interoperability – Improved support for dynamic languages

47 Recommended Books ● Pro C# 2008 and the.NET 3.5 Platform, Fourth Edition - Andrew Troelsen – Fourth/dp/ /ref=sr_1_1?ie=UTF8&s=books&qid= &sr=1-1 Fourth/dp/ /ref=sr_1_1?ie=UTF8&s=books&qid= &sr=1-1 ● Programming C#: Building.NET Applications with C# - Jesse Liberty – Applications/dp/ /ref=sr_1_1?ie=UTF8&s=books&qid= &sr= Applications/dp/ /ref=sr_1_1?ie=UTF8&s=books&qid= &sr=8 ● Professional C# 2008 (Wrox Professional Guides) – Guides/dp/ /ref=sr_1_3?ie=UTF8&s=books&qid= &sr=1-3 Guides/dp/ /ref=sr_1_3?ie=UTF8&s=books&qid= &sr=1-3 ● C# in Depth: What you need to master C# 2 and 3 - Jon Skeet – master/dp/ /ref=sr_1_4?ie=UTF8&s=books&qid= &sr=1-4 master/dp/ /ref=sr_1_4?ie=UTF8&s=books&qid= &sr=1-4

48 Resources and further reading ● ● Programmers overview ● Comparison of C# to Java PDF - ava%20and%20CSharp.pdf ava%20and%20CSharp.pdf ● C# for C++ programmers -