540 likes | 708 Views
Developing Windows and Web Applications using Visual Studio.NET. Drew Robson. Agenda. About SSW and Presenters Student Introduction Course Overview .NET Overview OOP VB.Net vs C# VS. Net Overview/ Demo Hands on lab. About SSW.
E N D
Developing Windows and Web Applications using Visual Studio.NET Drew Robson
Agenda About SSWand Presenters Student Introduction Course Overview .NET Overview OOP VB.Netvs C# VS. Net Overview/ Demo Hands on lab
About SSW • SSW Consulting has 18 years development / consulting experience. • Adam Cogan is the Chief Software Architect at SSW • 1of 3 Microsoft Regional Directors in Australia
Drew Robson • Senior Software Architect @ SSW • Loves C# and .NET • Specializes in • Windows Forms • ASP.NET • ASP.NET MVC • TFS
Admin Stuff • Attendance • Please initial the sheet next to your name • Hands On Lab • Homework • Certificate • At end of 10 sessions
Introductions • Name • Company • Experience • IT • Programming • .NET • C# / VB • Database • Goals for the course Anything else after 9PM
Session 1: Overview This session will cover • What is .NET? • Language Differences VB + C# • Review of OOP • N-Tier Solution Design • Demo: Creating WinForms
What is .NET? .NET is the Microsoft Web services strategy to connect information, people, systems, and devices through software Microsoft, beginning 2000
What is .NET? • An application development platform from Microsoft • Runtime (Virtual machine) • Tools • Languages, IDE, … • Rapidly develop secure and robust software • Web and Windows • Full support for object-oriented programming
Compiles to MSIL Represents codeindependent from src Executes MSIL
What is .NET? • Language Independence • VB • C# • F# • C++ • IronPython • Any language that supports the Common Language Runtime (CLR) Specification
Tools • C:\Windows\Microsoft.NET
History of .NET and Visual Studio • 2002 - .Net 1.0 / Visual Studio.NET • 2003 - .Net 1.1 / Visual Studio 2003 • 2005 - .Net 2.0 / Visual Studio 2005 • 2007 - .Net 3.5 / Visual Studio 2008 • 2008 - .Net 3.5sp1 (added EDMX) • 2010 - .Net 4.0 / Visual Studio 2010 • 2012 - .Net 4.5 / Visual Studio 2012
What is the .NET Framework? • Over 4500 classes that provides features such as: • Data access and connectivity (ADO.NET) • User Interfaces (WinForms, WPF) • Web Applications (ASP.NET, Silverlight) • Network Communication (WCF) • Workflow (WF)
.NET Framework • Evolution • The whole .NET FX 3.5 • Further improvements in .NET 4 • Win8 devices, parallel computing,HTML5 in .NET 4.5
CLR =Common Language Runtime • Allows for language independence • Memory Management (allocation and de-allocation of memory) • Performs automatic garbage collection with the elimination of pointers • No more memory leaks (in theory at least!) • Exception Handling • Security (sandbox from the OS– cannot run malicious code) • Converts the IL byte code into runtime code
C# ? • Main programming language for .NET framework • Based on C • Built with hindsight • Java Very similar to Java • C++ Very similar to C++ • A ‘modern language’ that did not inherit the ‘junk’ from C++ (eg header files, syntax)
C# Basis • Variable declaration bool isVeryLong; • Variable assignment isVeryLong = false; • Control statements if (yourInput.Length > 10) { isVeryLong = true; }
History C# - Anders Hejlsberg • C# 1.0 – first Version • C# 2.0 – Everything that didn’t fit in 1.0 • C# 3.0 – LINQ, functional influence • C# 4.0 – Dynamic Programming • C# 4.5 – Devices and Web • C# 5.0 …?
Terms - I want you to know • Classes • Objects • Properties • Methods • Events #1 Inheritance #2 Encapsulation #3 Polymorphism #4 Abstraction
Class vs Object Class • Defines abstract characterizations of a “thing” • Customer • Employee • Car • Blueprint or template • Object • Instance of a class • “Car” has an instance called “petersCar”
Terms • Properties • Changeable features of objects • Eg. „Color“ of a car • Methods • Actions on an object • Eg. Car has a method „Accelerate“ • Events • Let other objects know about an action • Eg. Car has an event „DoorOpened“
#1 Inheritance • A "square" is a "shape"
A "shape" defines a common property "Color" • A "square" inherits the property "Color"
#2 Encapsulation • Information hiding • E.g.A shape hides internal data • 1st point • 2nd point
#3 Polymorphism • Appear as another • Be used like another
#3 Polymorphism var shapes = new List<IShapes>() { new Square(“Red"), new Rectangle(“Blue"), new Triangle(“Red") }; foreach (var shape in shapes) { Console.WriteLine(shape.Color + ": " + shape.CalcSize()); }
#4 Abstraction • Allows inheritance but no instantiation
Language Differences Variables ' VB.NET DimFavouriteColourAsString = "LightGreen" // C# StringFavouriteColour = "LightGreen";
Language Differences Methods 'VB.NET Public Function GetName () As String Public Sub DoSomething() //C# public string GetName() {} public void DoSomething() {}
Language Differences Events and Methods
Language Differences VB.NET Properties PublicPropertyFirstName() AsString Get ReturnpFirstName EndGet Set(ByVal value AsString) pFirstName = value EndSet EndProperty
Language Differences C# Properties private string firstName; public StringFirstName{ get { returnfirstName } set { firstName= value; } }
Properties since C# 3.0 Automatic Properties Feature public StringFirstName{ get; set;} Notice no internal variable was declared? It is created by the compiler Saves typing and makes code neater
.NET 3.5 • Auto Implemented Properties • Collection Initializers (limited) • Named parameters • Optional parameters • Lambdas (limited) • Can span statements across multiple lines • Auto Implemented Properties • Collection Initializers • Named parameters • Optional parameters • Lambdas • Can span statements across multiple lines
.NET 4 • Auto Implemented Properties • Collection Initializers • Named parameters • Optional parameters • Lambdas • Can span statements across multiple lines • Auto Implemented Properties • Collection Initializers • Named parameters • Optional parameters • Lambdas • Can span statements across multiple lines
What is a Form? • A UI Component • WinForm – a Window displayed by an application • Web Forms are page hosted in a browser
Controls • Textboxes • Buttons • Tool Strip Menu • Picture • Labels
User Controls • Reuse a set of controls • e.g. Form with • Billing Address and • Shipping Address Where an address consists of • Address line 1 • Address line 2 • Suburb • State • Post code
Events • Most controls have events • Examples • Clicked • TextChanged • Closing • Event Handlers • Can’t control the order the event gets handled
Summary • The 10 Sessions • Overview of .NET • C#, and how it differs to VB.Net • OOP • Demo: Creating WinForms (C#)
Hands ON LAB • Creating a Windows Form Application • Opening forms • Menus • Event handlers • User controls