Getting Started with Microsoft Visual Studio,.NET and C# Jim Warren, COMPSCI 280 S2 2015 Enterprise Software Development.

Slides:



Advertisements
Similar presentations
Introduction to .NET Framework
Advertisements

© by Pearson Education, Inc. All Rights Reserved.
Visual Basic 2010 How to Program. © by Pearson Education, Inc. All Rights Reserved.2.
Visual Basic 2010 How to Program Reference: Instructor: Maysoon Bin Duwais slides Visual Basic 2010 how to program by Deitel © by Pearson Education,
.NET Framework Overview Pingping Ma Nov 16 th, 2006.
Getting Started with Microsoft Visual Studio,.NET and C# Jim Warren, COMPSCI 280 S Enterprise Software Development.
Introduction to the C# Programming Language for the VB Programmer.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
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.
Object Oriented Software Development 1. Introduction to C# and Visual Studio.
Intro to dot Net Dr. John Abraham UTPA – Fall 09 CSCI 3327.
2. Introduction to the Visual Studio.NET IDE 2. Introduction to the Visual Studio.NET IDE Ch2 – Deitel’s Book.
Microsoft Visual Basic 2012 CHAPTER ONE Introduction to Visual Basic 2012 Programming.
Microsoft Visual Basic 2005 CHAPTER 1 Introduction to Visual Basic 2005 Programming.
Creating and Running Your First C# Program Telerik Software Academy Telerik School Academy.
A First Program Using C#
Introduction to.Net and ASP.Net Course Introduction Build Your Own ASP.Net Website: Chapter 1 Microsoft ASP.Net Walkthrough: Creating a Basic Web Forms.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
© 2004 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin Programming the Web Using ASP.Net Chapter 2: The ASP.Net Template Dave.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
1 Introduction to.NET Framework. 2.NETFramework Internet COM+ Orchestration Orchestration Windows.NET Enterprise ServersBuildingBlockServices Visual Studio.NET.
Introduction to .Net Framework
Introduction to ASP.NET. Prehistory of ASP.NET Original Internet – text based WWW – static graphical content  HTML (client-side) Need for interactive.
NOTE: To change the image on this slide, select the picture and delete it. Then click the Pictures icon in the placeholder to insert your own image. WEB.
1 8/29/05CS360 Windows Programming Professor Shereen Khoja.
© 2008 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott COMP6325 Advanced Web Technologies Dr. Paul Walcott The University.
Intro to C# Dr. John P. Abraham UTPA. Background required Thorough C++ programming – If you made an A in 1370/1170 you will do fine with some effort.
Module 1: Introduction to C# Module 2: Variables and Data Types
Microsoft Visual Basic 2005: Reloaded Second Edition
Lecture Set 1 Part B: Understanding Visual Studio and.NET – Structure and Terminology 1/16/ :04 PM.
Creating and Running Your First C# Program Svetlin Nakov Telerik Corporation
Lesley Bross, August 29, 2010 ArcGIS 10 add-in glossary.
IE 411/511: Visual Programming for Industrial Applications
ASP.NET Web Application and Development Digital Media Department Unit Credit Value : 4 Essential Learning time : 120 hours Digital.
Lecture 1 Programming in C# Introducing C# Writing a C# Program.
E-Commerce: Introduction to Web Development 1 Dr. Lawrence West, Management Dept., University of Central Florida Topics What is a Web.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
2. Introduction to the Visual Studio.NET IDE. Chapter Outline Overview of the Visual Studio.NET IDE Overview of the Visual Studio.NET IDE Menu Bar and.
Lecture Set 1 Part C: Understanding Visual Studio and.NET – Applications, Solutions, Projects (no longer used – embedded in Lecture Set 2A)
The Web Architecture and ASP.NET. Slide 2 Review of the Web (1) It began with HTTP and HTML, which delivers static Web pages to browsers which would render.
NOTE: To change the image on this slide, select the picture and delete it. Then click the Pictures icon in the placeholder to insert your own image. WEB.
Lecture Set 2 Part A: Creating an Application with Visual Studio – Solutions, Projects, Files.
Introduction to ASP.NET T.Ahlam Algharasi. The Visual Studio IDE Start page 2.
Rajiv and Shipra Introduction to.NET (asp.net,c#,vb)
Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,
PRIOR TO WEB SERVICES THE OTHER TECHNOLOGIES ARE:.
BIL527 – Bilgisayar Programlama I Introduction 1.
Getting Started with.NET Getting Started with.NET/Lesson 1/Slide 1 of 31 Objectives In this lesson, you will learn to: *Identify the components of the.NET.
Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Chapter 2 Introduction to Visual Basic Programming Visual Basic.NET.
Object-Oriented Application Development Using VB.NET 1 Chapter 2 The Visual Studio.NET Development Environment.
Lecture Set 2 Part A: Creating an Application with Visual Studio – Solutions, Projects, Files 8/10/ :35 PM.
1 Getting Started with C++ Part 1 Windows. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Microsoft.
Text Introduction to.NET Framework. CONFIDENTIAL Agenda .NET Training – Purpose  What is.NET?  Why.NET?  Advantages  Architecture  Components: CLR,
Lecture Set 1 Part B: Understanding Visual Studio and.NET – Structure and Terminology 1/16/ :04 PM.
Microsoft Visual Basic 2015 CHAPTER ONE Introduction to Visual Basic 2015 Programming.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
A Detailed Introduction To Visual Studio.NET CRB Tech ReviewsCRB Tech Reviews introduces you to the world of Visual.
Chapter 1 Getting Started with ASP.NET Objectives Why ASP? To get familiar with our IDE (Integrated Development Environment ), Visual Studio. Understand.
Introduction ITEC 420.
Dive Into® Visual Basic 2010 Express
Chapter 2: The Visual Studio .NET Development Environment
Introduction to Visual Basic 2008 Programming
Introduction to .NET Framework Ch2 – Deitel’s Book
Introduction to C# AKEEL AHMED.
CIS16 Application Development – Programming with Visual Basic
IS 135 Business Programming
Presentation transcript:

Getting Started with Microsoft Visual Studio,.NET and C# Jim Warren, COMPSCI 280 S Enterprise Software Development

Welcome (to this part of 280)!  Your lecturer: Jim Warren   x86422  Office: 303S-483  Office hours: by arrangement (try first, and we’ll start an FAQ for assignment 2)  These 4 weeks will provide you skills to create.NET applications in C# and to connect them to an underlying database  There’s a lab sheet for each week to walk through programming methods  The tutor will also reinforce the topics from lecture Handout 01COMPSCI 2802

Assignment 2  Create a.NET C# console application  Does database connection, query and update from C#  Includes interpretation and validation of user input  Assignment spec on course website  Due noon Friday on week 8 (25 th September)  Worth 5% of course mark  Do the first two.NET/C# labsheets and then get into the assignment before the break! Handout 01COMPSCI 2803

Today’s learning objectives  To be introduced to the.NET framework, including Visual Studio and C#  To be able to describe characteristics of the Common Language Runtime  To be able to describe the general characteristics of some important project templates  Console application  Windows Forms application  ASP MVC Web application (Well, we’ll just get a glance at these today, but we’ll learn them in more depth as we go) Handout 01COMPSCI 2804

Visual Studio (VS)  For Assignment 2, we will use Visual Studio to do our application programming  What is Visual Studio?  Visual Studio is an example of an "Integrated Development Environment" (IDE)  Think of an IDE as an application that combines code editor, compiler, debugging and other tools that make the design, maintenance, and documentation of large projects easier  Why an IDE?  Maybe you’ve had the experience of how Java projects consist of multiple files for different classes  This is characteristic for large projects  In MVC applications we’ll see that we have many types of files (for ‘M’, ‘V’, and ‘C’, and various aspects of the website template, system configuration and helper functions)  VS lets us manage these features and content in a convenient way Handout 015COMPSCI 280

Visual Studio and C#  Helpful background reading  Visual Studio from the Microsoft Developer Network (MSDN) us/library/dd831853(v=vs.120).aspx (particularly note the Visual Studio IDE User Guide and the Application Development in Visual Studio links). us/library/dd831853(v=vs.120).aspx  C# introduction   VS supports multiple languages (C#, C++, Visual Basic, J#) in the one IDE  All with nearly identical functionality and performance because the use a common core  VS produces many types of applications  It can also integrate with Microsoft Office applications (Word, Excel, etc.) Handout 016COMPSCI 280

.NET Languages  All Visual Studio.NET languages are object-oriented  True inheritance and polymorphism (ability to redefine methods for derived classes) are supported  No matter the language, all programs have a similar structure  Note that if you've done some kind of BASIC (e.g. VB 6) in the past - the language has changed considerably!  C# (C-sharp) is relatively a new language  With syntax similar to C++, but also borrowing a lot of ideas from Java  Visual J# is also a new language  with syntax similar to Java  File structure is similar for all languages  Files are grouped into projects  All programs compiled into Common Intermediate Language (CIL)  Also known as Microsoft Intermediate Language (MSIL) Handout 017COMPSCI 280

The.NET Framework  The.NET Framework define the rules for language interoperability and how an application is compiled into executable code.  It is also responsible for managing the execution of an application created in any VS.NET language.  The.NET Framework has two main components: the common language runtime (CLR) and the.NET Framework class library.  CLR  Manages memory, thread execution, code execution, code safety verification, compilation, and other system services  Memory allocation, starting up and stopping processes  The.NET Framework class library  Provides developers with a unified, object-oriented, hierarchical and extensible set of class libraries (‘application programmer interfaces’, APIs) Handout 018COMPSCI 280

Execution Management  The managed execution process includes the following steps:  Choosing a compiler  Compiling, code -> CIL/MSIL  Compiling translates the source code into CIL and generates the required metadata (this package is an ‘assembly’ (e.g. a DLL is an assembly)  The format is similar to assembly language but is hardware independent  Compiling, CIL -> native code  A just-in-time (JIT) compiler translates the assembly into native code (or runs it in a virtual machine)  Conceptually, the process is similar to the Java Virtual Machine  Running code  The CLR provides the infrastructure that enables managed execution to take place as well as a variety of services that can be used during execution. Handout 01COMPSCI 2809 Source code Language Specific Compiler Language Specific Compiler EXE/DLL (CIL and metadata) CompilingRunning Engine JIT Compiler Native Code Execution

Garbage Collection  The CLR performs memory management  It manages the allocation and release of memory for an application  Automatic memory management can eliminate common problems,  such as forgetting to free an object and causing a memory leak, (common problems in C and C++ that lack garbage collection!) or  attempting to access memory for an object that has already been freed.  A contiguous area of memory allocated to a process is called the managed heap  Reference types are allocated from the managed heap  The CLR reclaims memory using the Garbage Collector (GC)  The GC examines variables to reclaim unused memory  It looks for memory without a corresponding variable (root) Handout 0110COMPSCI 280

Namespace  Physical assemblies are organized into logical components called namespaces  Namespaces are organized into a hierarchy  Microsoft has divided VS.NET into two primary namespaces:  The System namespace contains components developed by the.NET team  The Microsoft namespace contains components developed by Microsoft but outside of the.NET development team  Common Namespaces:  The ‘System’ namespace contains fundamental classes  System.Data namespace contains classes supplying data access capabilities  As compared to e.g. Microsoft.Media.AdaptiveStreaming Namespace (we’ll mostly use parts of the System namespace)  You’ll create namespaces for your own content (e.g. the data ‘model’ in your MVC application) Handout 0111COMPSCI 280

Creating a Console Application with VS  Open Visual Studio  To create a new project called HelloWorldApp  Choose File->New Project  Select the project type: Visual C#  Select the project template: Console Application  Enter a name, Select a save Location and enter solution Name  Select Create directory for solution  Click OK – a program skeleton with a Main method that appears in the editor  Insert the following code:  Note:  The Main method is the entry point of your program, where the program control starts and ends  Insert Console.ReadLine() to the Main method which causes the program to pause until ENTER is pressed  To run your application  Press F5 to run the application, or  Click the ‘Start’ button (with the green triangle [‘play’] icon) Handout 03COMPSCI Console.WriteLine("Hello World"); Console.ReadLine();

Creating a Windows Forms application  This type of project starts with a blank form  You can drag and drop useful components onto the form from the ‘Toolbox’ (available under the View menu) Handout 01COMPSCI  Use the Properties window to edit attributes of the selected control  Double-click a control to add code into its event handler  E.g. MessageBox.Show(" Hello, world!");

The Model-View-Controller approach  MVC is an architectural pattern  Well, it’s ‘architectural’ when you make a project with directories for the 3 areas of concern; conceptually, it’s a design pattern  Separates responsibilities in the application  Model – the data (including the connection and mapping to the DBMS) and its integrity constraints (e.g. legal values of variables in terms of the domain logic)  View – the rendering. What it looks like to the user and the detail of how they interact with the application  Controller – Handles and responds to user interaction. Uses the model and selects the next view to offer the user. Handout 01COMPSCI See

An MVC Project in VS  Open VS  File/New Project… select Visual C# -> Web -> ASP.NET Web Application and the MVC template  Give it a name and location  Press OK and listen to the hard drive grind  Solution Explorer (righthand side of screen in IDE) produces folders for the Controllers, Models and Views (alphabetical order)  The default template includes account management (login, new user) MVC elements Handout 01COMPSCI 28015

MVC application from the template Handout 01COMPSCI Runs at ‘localhost’ served up by the built-in IIS Express local Web server

The Controller  The controller has a method of type ActionResult for each webpage in the solution  This is run when the application serves up that page  The ViewBag object is dynamic; shortcut for tossing data to the View  C# moment: note the “:” operator to indicate deriving a child class from a base class Handout 01COMPSCI using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace WebApplication1.Controllers { public class HomeController : Controller { public ActionResult Index() { return View(); } public ActionResult About() { ViewBag.Message = "Your application description page."; return View(); } public ActionResult Contact() { ViewBag.Message = "Your contact page."; return View(); }

The View  One.cshtml (C# HTML) file for each page of the solution  Here we have the HTML for what the user sees on the index / home page  But it’s not just HTML Handout 01COMPSCI ViewBag.Title = "Home Page"; } ASP.NET ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript. Learn more »...  indicates Razor Syntax markup that is converted at run-time into HTML  Can be a code block (essentially C# syntax inside curly braces)  Or can be an expression )

Conclusion .NET is a framework for creating applications featuring  Common language run-time (CLR) .NET Framework class library  The CLR provides execution management  Just-in-time compiling  Memory management (via garbage collection)  Visual Studio (VS) is an integrated development environment (IDE) for.NET  Allows you develop in any of several languages, including VB and C#  VS provides a number of application templates  Can create terminal, Windows or Web applications  Next – we’ll get into C# as a language… Handout 01COMPSCI 28019