Keith Elder Microsoft MVP

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

The Line Class Suppose you are involved in the development of a large mathematical application, and this application needs an object to represent a Line.
Written by: Dr. JJ Shepherd
Chapter 7: User-Defined Functions II
Introduction to the C# Programming Language for the VB Programmer.
Road Map Introduction to object oriented programming. Classes
Access to Names Namespaces, Scopes, Access privileges.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
1 Chapter 4 Language Fundamentals. 2 Identifiers Program parts such as packages, classes, and class members have names, which are formally known as identifiers.
Names and Scopes CS 351. Program Binding We should be familiar with this notion. A variable is bound to a method or current block e.g in C++: namespace.
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++
Arrays. A group of data with same type stored under one variable. It is assumed that elements in that group are ordered in series. In C# language arrays.
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
© The McGraw-Hill Companies, 2006 Chapter 5 Arrays.
ECE122 L11: For loops and Arrays March 8, 2007 ECE 122 Engineering Problem Solving with Java Lecture 11 For Loops and Arrays.
1 Chapter 2 Introductory Programs. 2 Getting started To create and run a Java program –Create a text file with a.java extension for the source code. For.
28-Jun-15 Access to Names Namespaces, Scopes, Access privileges.
Programming Concepts MIT - AITI. Variables l A variable is a name associated with a piece of data l Variables allow you to store and manipulate data in.
C# Tutorial From C++ to C#. Some useful links Msdn C# us/library/kx37x362.aspxhttp://msdn.microsoft.com/en- us/library/kx37x362.aspx.
The Ruby Programming Language
3.1 Documentation & Java Language Elements Purpose of documentation Assist the programmer with developing the program Assist other programers who.
11 Values and References Chapter Objectives You will be able to: Describe and compare value types and reference types. Write programs that use variables.
1. 2 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Decisions { class.
220 FINAL TEST REVIEW SESSION Omar Abdelwahab. INHERITANCE AND POLYMORPHISM Suppose you have a class FunClass with public methods show, tell, and smile.
1.  Collections are data structures that holds data in different ways for flexible operations  C# Collection classes are defined as part of the ◦ System.Collections.
Introduction to Classes SWE 344 Internet Protocols & Client Server Programming.
Distributed Systems (236351) Tutorial 1 - Getting Started with Visual Studio C#.NET.
07 Coding Conventions. 2 Demonstrate Developing Local Variables Describe Separating Public and Private Members during Declaration Explore Using System.exit.
The Java Programming Language
C#C# Introduction CS3260 Dennis A. Fairclough Version 1.0 Introduction CS3260 Dennis A. Fairclough Version 1.0.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
Chapter 6Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Chapter 6 l Array Basics l Arrays and Methods l Programming with Arrays.
Module 3: Working with Components. Overview An Introduction to Key.NET Framework Development Technologies Creating a Simple.NET Framework Component Creating.
Session 08 Module 14: Generics and Iterator Module 15: Anonymous & partial class & Nullable type.
ILM Proprietary and Confidential -
Stacks. A stack is a data structure that holds a sequence of elements and stores and retrieves items in a last-in first- out manner (LIFO). This means.
Variables and Functions. Open your Encoder program Let’s begin by opening the “Labyrinth Auto Straight” code. Save this file as Labyrinth with variables.
C# Programming Fundamentals Control Flow Jim Warren, COMPSCI 280 S Enterprise Software Development.
Using Data Within a Program Chapter 2.  Classes  Methods  Statements  Modifiers  Identifiers.
C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.
Basic Java Syntax COMP 401, Spring 2014 Lecture 2 1/14/2014.
C# Classes and Inheritance CNS 3260 C#.NET Software Development.
AP Computer Science edition Review 1 ArrayListsWhile loopsString MethodsMethodsErrors
Hello Computer Science!. Below is an example of a Hello World program in JAVA. While it is only three lines of code, there are many things that are happening.
CIS 270—Application Development II Chapter 8—Classes and Objects: A Deeper Look.
Advanced Programming C# Introduction.
PROGRAMMING IN C#. Collection Classes (C# Programming Guide) The.NET Framework provides specialized classes for data storage and retrieval. These classes.
Programmeren 1 6 september 2010 HOORCOLLEGE 2: INTERACTIE EN CONDITIES PROGRAMMEREN 1 6 SEPTEMBER 2009 Software Systems - Programming - Week.
General Computer Science for Engineers CISC 106 Lecture 12 James Atlas Computer and Information Sciences 08/03/2009.
Arrays-. An array is a way to hold more than one value at a time. It's like a list of items.
Written by: Dr. JJ Shepherd
An Introduction to Java – Part 1 Erin Hamalainen CS 265 Sec 001 October 20, 2010.
Object Oriented Programming Session # 03.  Abstraction: Process of forming of general and relevant information from a complex scenarios.  Encapsulation:
Array in C++ / review. An array contains multiple objects of identical types stored sequentially in memory. The individual objects in an array, referred.
Introduction to C# Anders Hejlsberg Distinguished Engineer Developer Division Microsoft Corporation.
Array Size Arrays use static allocation of space. That is, when the array is created, we must specify the size of the array, e.g., int[] grades = new int[100];
© 2006 Pearson Addison-Wesley. All rights reserved 1-1 Chapter 1 Review of Java Fundamentals.
5.1 Basics of defining and using classes A review of class and object definitions A class is a template or blueprint for an object A class defines.
Programming for Interactivity Professor Bill Tomlinson Tuesday & Wednesday 6:00-7:50pm Fall 2005.
C# Fundamentals An Introduction. Before we begin How to get started writing C# – Quick tour of the dev. Environment – The current C# version is 5.0 –
Features of.net Language independent Object oriented program Multi threading Exception handling Drag and drop Linq
CLASSES IN JAVA Primitive Types Example of a Class Allocating Objects of a Class Protecting Class data Constructors Static data and Static Methods.
Midterm preview.
Class Structure 15-Jun-18.
Class Structure 28-Nov-18.
CHAPTER 6 GENERAL-PURPOSE METHODS
Namespaces, Scopes, Access privileges
CIS 199 Final Review.
Introduction to Programming
Presentation transcript:

Keith Elder Microsoft MVP

Assumptions I assume you Have 1 – 2 years of programming experience Understand the basic concepts of Variables Loops Arrays Can type over 40 words per minute

Very Simple Program A C# program requires one Main method. This is the entry point to the program. All code is held within a class. Blocks of code are represented with curly braces {}. Each line ends with a semi-colon; C# is a strongly typed language. C# is an object oriented language class MyFirstProgram { static void Main() { int x = 5; int y = 10; int z = x + y; } C# Quick Facts

Breaking Down C# - Namespace Namespace Abstract container providing organization to items. Typically organized by: Company Product Team Sub-Team Etc. Namespace Class Method1 Method2 Properties (data)

Breaking Down C# - Namespace namespace SkunkWorks { public class Loan { public decimal LoanAmount { get; set; } public bool IsApproved { get; set; } } namespace Vendor { public class Loan { public decimal LoanAmount { get; set; } public bool IsApproved { get; set; } public int CreditScore { get; set; } }

Breaking Down A C# - Class A class is just a blue print for an object. An object is an allocated region of storage. An object doesn’t exist until memory is allocated. A class holds data (properties/fields) and is made up of one or more methods (functions). Namespace Class Method1 Method2 Properties (data)

Breaking Down C# – Class / Properties namespace SkunkWorks { public class Loan { public decimal LoanAmount { get; set; } public bool IsApproved { get; set; } } Loan myLoan = new Loan(); When an instance of a Loan is created in memory, this becomes an object. Thus the variable myLoan is an object. Properties Class

Breaking Down C# - Method Think of methods as actions that classes can perform. Take a function, put it in a class, we call it a method. C# doesn’t allow functions to live and breathe outside of a class. Thus, all we have is methods. Methods can access other methods within the class and properties, and call other methods in other classes. public class Loan { public decimal LoanAmount { get; set; } public bool IsApproved { get; set; } public void MarkApproved() { IsApproved = true; OnMarkedApproved(); }

Putting it all together namespace ConsoleApplication { class Program { static void Main() { Loan myLoan = new Loan(); myLoan.LoanAmount = ; } Using statements specify which Namespaces to use to resolve classes. using System; using Vendor;

All Lines Must End in ; Correct Incorrect int x = 5;int x = 5

Variables Must Declare Type Correct Incorrect int x = 5;x = 5;

Supported C# Types C# type keywords.Net Framework Type boolSystem.Boolean byteSystem.Byte sbyteSystem.Sbyte charSystem.Char decimalSystem.Decimal doubleSystem.Double floatSystem.Single intSystem.Int32 unitSystem.UInt32 longSystem.Int64 ulongSystem.UInt64 objectSystem.Object shortSysytem.Int16 ushortSystem.UInt16 stringSystem.String

Type Cannot Be Changed Correct Incorrect int x = 5; x = “foo”; Compilation error

Strings must be in quotes Correct Incorrect string x = “foo bar”; string x = foo bar; TIP: If foo is declared as a variable of type string this is legal.

If / Else if (expression) { } else { } if (expression) { } else if (expression) { } else { } int x = 5; if (x > 5) { x = 10; } else { x = 0; } TIP: If you only have one line in your if block, you can skip the curly braces. int x = 5; If (x % 2 == 0) CallSomeMethod();

C# Is Strongly Typed Correct Incorrect z = 5; name = “Anders”; int z = 5; string name = “Anders”; You have to tell the compiler what type of data you are storing. shortintlong

Commenting Code // single lines /// for summaries /* */ block //int x = 5; /// /// This is what kicks the program off. /// static void Main(string[] args) { } /* this is a comment */

Operators C# uses standard mathematical operators +, -, /, *,, =, Expression operators && || == != Assignment operators =, +=, *=, -=, *=

Who can see what? Public means that anyone can access it Private means that only other members can access it public class Loan { public decimal LoanAmount { get; set; } public bool IsApproved { get; set; } private bool DocsCompleted { get; set; } }

Static Keyword Can be used with Fields Methods, Properties Operators Events Constructors Cannot be used with indexers and desconstructors

Static Keyword Referenced through the type not the instance

Loops Foreach loops For loops While loops foreach (var item in collection) { Console.WriteLine(item.Property); } for (int i = 0; i < length; i++) { Console.WriteLine(i); } while (expression) // x < 5 { } TIP: Use code snippets to stub these out.

(section not finished)

Nullable Types

Collections Arrays ArrayList List Generic collections

Generics

Value Type vs Reference Type

Reading / Writing Files

LINQ

XML

Handling Exceptions Try / Catch / Finally

Regular Expressions

Reflection