Microsoft Official Course. Review of Visual C# Syntax. (Module 1)

Содержание

Слайд 2

Module Overview Overview of Writing Application by Using Visual C# Data

Module Overview

Overview of Writing Application by Using Visual C# Data Types, Operators,

and Expressions Visual C# Programming Language Constructs
Слайд 3

Lesson 1: Overview of Writing Application by Using Visual C# What

Lesson 1: Overview of Writing Application by Using Visual C#

What Is

the .NET Framework? Key Features of Visual Studio 2012 Templates in Visual Studio 2012 Creating a .NET Framework Application Overview of XAML
Слайд 4

What Is the .NET Framework? CLR Robust and secure environment for

What Is the .NET Framework?

CLR
Robust and secure environment for your managed

code
Memory management
Multithreading
Class library
Foundation of common functionality
Extensible
Development frameworks
WPF
Windows store
ASP.NET
WCF
Слайд 5

Key Features of Visual Studio 2012 Intuitive IDE Rapid application development

Key Features of Visual Studio 2012

Intuitive IDE
Rapid application development
Server and data

access
IIS Express
Debugging features
Error handling
Help and documentation
Слайд 6

Templates in Visual Studio 2012 Console Application Windows Forms Application WPF

Templates in Visual Studio 2012

Console Application
Windows Forms Application
WPF Application
Windows Store
Class Library
ASP.NET

Web Application
ASP.NET MVC 4 Application
WCF Service Application
Слайд 7

Creating a .NET Framework Application In Visual Studio, on the File

Creating a .NET Framework Application

In Visual Studio, on the File menu,

point to New, and then click Project.
In the New Project dialog box, choose a template, location, name, and then click OK.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args) { }
}
}

Слайд 8

Overview of XAML XML-based language for declaring UIs Uses elements to

Overview of XAML

XML-based language for declaring UIs
Uses elements to define controls
Uses

attributes to define properties of controls

Слайд 9

Lesson 2: Data Types, Operators, and Expressions What are Data Types?

Lesson 2: Data Types, Operators, and Expressions

What are Data Types? Expressions and

Operators in Visual C# Declaring and Assigning Variables Accessing Type Members Casting Between Data Types Manipulating Strings
Слайд 10

What are Data Types? int – whole numbers long – whole

What are Data Types?

int – whole numbers
long – whole numbers (bigger

range)
float – floating-point numbers
double - double precision
decimal - monetary values
char - single character
bool - Boolean
DateTime - moments in time
string - sequence of characters
Слайд 11

Expressions and Operators in Visual C# Example expressions: + operator /

Expressions and Operators in Visual C#

Example expressions:
+ operator
/ operator
+ and –

operators
+ operator (string concatenation)

a + 1

5 / 2

a + b - 2

"ApplicationName: " + appName.ToString()

Слайд 12

Declaring and Assigning Variables Declaring variables: Assigning variables: Implicitly typed variables:

Declaring and Assigning Variables

Declaring variables:
Assigning variables:
Implicitly typed variables:
Instantiating object variables by

using the new operator

int price;
// OR
int price, tax;

price = 10;
// OR
int price = 10;

var price = 20;

ServiceConfiguration config = new ServiceConfiguration();

Слайд 13

Accessing Type Members Invoke instance members Example: var config = new

Accessing Type Members

Invoke instance members
Example:

var config = new ServiceConfiguration();
// Invoke the

LoadConfiguration method.
config.LoadConfiguration();
// Get the value from the ApplicationName property.
var applicationName = config.ApplicationName;
// Set the .DatabaseServerName property.
config.DatabaseServerName = "78.45.81.23";
// Invoke the SaveConfiguration method.
config.SaveConfiguration();

.

Слайд 14

Casting Between Data Types Implicit conversion: Explicit conversion: System.Convert conversion: int

Casting Between Data Types

Implicit conversion:
Explicit conversion:
System.Convert conversion:

int a = 4;
long b

= 5;
b = a;

int a = (int) b;

string possibleInt = "1234";
int count = Convert.ToInt32(possibleInt);

Слайд 15

Manipulating Strings Concatenating strings Validating strings StringBuilder address = new StringBuilder();

Manipulating Strings

Concatenating strings
Validating strings

StringBuilder address = new StringBuilder();
address.Append("23");
address.Append(", Main Street");
address.Append(", Buffalo");
string

concatenatedAddress = address.ToString();

var textToTest = "hell0 w0rld";
var regularExpression = "\\d";
var result = Regex.IsMatch(textToTest, regularExpression, RegexOptions.None);
if (result)
{
// Text matched expression.
}

Слайд 16

Lesson 3: Visual C# Programming Language Constructs Implementing Conditional Logic Implementing

Lesson 3: Visual C# Programming Language Constructs

Implementing Conditional Logic Implementing Iteration Logic Creating

and Using Arrays Referencing Namespaces Using Breakpoints in Visual Studio 2012 Demonstration: Developing the Class Enrollment Application Lab
Слайд 17

Implementing Conditional Logic if statements select statements if (response == "connection_failed")

Implementing Conditional Logic

if statements
select statements

if (response == "connection_failed") {. . .}
else

if (response == "connection_error") {. . .}
else { }

switch (response)
{
case "connection_failed":
. . .
break;
case "connection_success":
. . .
break;
default:
. . .
break;
}

Слайд 18

Implementing Iteration Logic for loop foreach loop while loop do loop

Implementing Iteration Logic

for loop
foreach loop
while loop
do loop

for (int i = 0

; i < 10; i++) { ... }

string[] names = new string[10];
foreach (string name in names) { ... }

bool dataToEnter = CheckIfUserWantsToEnterData();
while (dataToEnter)
{
...
dataToEnter = CheckIfUserHasMoreData();
}

do
{
...
moreDataToEnter = CheckIfUserHasMoreData();
} while (moreDataToEnter);

Слайд 19

Creating and Using Arrays C# supports: Single-dimensional arrays Multidimensional arrays Jagged

Creating and Using Arrays

C# supports:
Single-dimensional arrays
Multidimensional arrays
Jagged arrays
Creating an array
Accessing data

in an array:
By index
In a loop

int[] arrayName = new int[10];

int result = arrayName[2];

for (int i = 0; i < arrayName.Length; i++)
{
int result = arrayName[i];
}

Слайд 20

Referencing Namespaces Use namespaces to organize classes into a logically related

Referencing Namespaces

Use namespaces to organize classes into a logically related hierarchy
.NET

Class Library includes:
System.Windows
System.Data
System.Web
Define your own namespaces:
Use namespaces:
Add reference to containing library
Add using directive to code file

namespace FourthCoffee.Console
{
class Program {. . .}

Слайд 21

Using Breakpoints in Visual Studio 2012 Breakpoints enable you to view

Using Breakpoints in Visual Studio 2012

Breakpoints enable you to view and

modify the contents of variables:
Immediate Window
Autos, Locals, and Watch panes
Debug menu and toolbar functions enable you to:
Start and stop debugging
Enter break mode
Restart the application
Step through code
Слайд 22

Demonstration: Developing the Class Enrollment Application Lab In this demonstration, you

Demonstration: Developing the Class Enrollment Application Lab

In this demonstration, you will

learn about the tasks that you will perform in the lab for this module.
Слайд 23

Text Continuation

Text Continuation

Слайд 24

Lab: Developing the Class Enrollment Application Exercise 1: Implementing Edit Functionality

Lab: Developing the Class Enrollment Application

Exercise 1: Implementing Edit Functionality for

the Students List Exercise 2: Implementing Insert Functionality for the Students List Exercise 3: Implementing Delete Functionality for the Students List Exercise 4: Displaying a Student’s Age

Logon Information

Virtual Machines: 20483B-SEA-DEV11, MSL-TMG1
User Name: Student
Password: Pa$$w0rd

Estimated Time: 105 minutes

Слайд 25

Text Continuation

Text Continuation

Слайд 26

Lab Scenario You are a Visual C# developer working for a

Lab Scenario

You are a Visual C# developer working for a software

development company that is writing applications for The School of Fine Arts, an elementary school for gifted children.
The school administrators require an application that they can use to enroll students in a class. The application must enable an administrator to add and remove students from classes, as well as to update the details of students.
You have been asked to write the code that implements the business logic for the application.
During the labs for the first two modules in this course, you will write code for this class enrollment application.
When The School of Fine Arts ask you to extend the application functionality, you realize that you will need to test proof of concept and obtain client feedback before writing the final application, so in the lab for Module 3, you will begin developing a prototype application and continue with this until then end of Module 8.
In the lab for Module 9, after gaining signoff for the final application, you will develop the user interface for the production version of the application, which you will work on for the remainder of the course.
Слайд 27

Module Review and Takeaways Review Question(s)

Module Review and Takeaways

Review Question(s)