.NET Data types. Introduction ٭ A "data type" is a class that is primarily used just to hold data. ٭ This is different from most other classes since they're.

Slides:



Advertisements
Similar presentations
Ch. 3 Variables VB.Net Programming. Data Types Boolean – True or False values Short – Small integers (+/- 32,767) Integer – Medium-size integers (+/-
Advertisements

CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 6 th Lecture Pavel Ježek
C# Language Report By Trevor Adams. Language History Developed by Microsoft Developed by Microsoft Principal Software Architect Principal Software Architect.
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Murach’s Visual Basic 2008, C4© 2008, Mike Murach & Associates, Inc. Slide 1.
Neal Stublen C# Data Types Built-in Types  Integer Types byte, sbyte, short, ushort, int, uint, long, ulong  Floating Point Types.
C#: Data Types Based on slides by Joe Hummel. 2 UCN Technology: Computer Science Content: “.NET is designed around the CTS, or Common Type System.
Chapter 3 Variables, Constants, and Calculations
© 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5/e Starting Out with C++: Early Objects 5 th Edition Chapter 2 Introduction.
22-Jun-15 Introduction to Primitives. 2 Overview Today we will discuss: The eight primitive types, especially int and double Declaring the types of variables.
IS437: Fall 2004 Instructor: Dr. Boris Jukic Data Types, Constants, Variables, Scope, Conversion.
3. Data Types. 2 Microsoft Objectives “.NET is designed around the CTS, or Common Type System. The CTS is what allows assemblies, written in different.
Lecture 2: Topics Bits and Bytes Primitive Types Casting Strings Boolean expressions.
Data Types 1.
1 Chapter Two Using Data. 2 Objectives Learn about variable types and how to declare variables Learn how to display variable values Learn about the integral.
Programming Principles Data types and Variables. Data types Variables are nothing but reserved memory locations to store values. This means that when.
Chapter 4 Introduction to Numeric Data Types and Variables.
1. 2 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Decisions { class.
CSC 125 Introduction to C++ Programming Chapter 2 Introduction to C++
Variable, Expressions, Statements and Operators By: Engr. Faisal ur Rehman CE-105 Fall 2007.
P Object type and wrapper classes p Object methods p Generic classes p Interfaces and iterators Generic Programming Data Structures and Other Objects Using.
Why does it matter how data is stored on a computer? Example: Perform each of the following calculations in your head. a = 4/3 b = a – 1 c = 3*b e = 1.
CH2 – Using Data. Constant Something which cannot be changed Data Type Format and size of a data item Intrinsic Data Types Pg. 47 – Table 2-1 Basic ones.
Chapter 2: Using Data.
Java Simple Types CSIS 3701: Advanced Object Oriented Programming.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
Applications Development
Computing with C# and the.NET Framework Chapter 2 C# Programming Basics ©2003, 2011 Art Gittleman.
C# C1 CSC 298 Elements of C# code (part 1). C# C2 Style for identifiers  Identifier: class, method, property (defined shortly) or variable names  class,
Copyright Curt Hill Variables What are they? Why do we need them?
Chapter 3 Variables, Constants and Calculations Programming In Visual Basic.NET.
Copyright © – Curt Hill Types What they do.
Java Programming, Second Edition Chapter Two Using Data Within a Program.
Data Tonga Institute of Higher Education. Variables Programs need to remember values.  Example: A program that keeps track of sales needs to remember.
1. 2 Framework Classes and libraries: 3.
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 8 th Lecture Pavel Ježek
Programming with Microsoft Visual Basic th Edition
CSI 3125, Preliminaries, page 1 Data Type, Variables.
How to execute Program structure Variables name, keywords, binding, scope, lifetime Data types – type system – primitives, strings, arrays, hashes – pointers/references.
Variables in VB.NET. Variables  A storage location in memory (RAM)  Holds data/information while the program is running  These storage locations can.
1.2 Primitive Data Types and Variables
Introduction ABAP Fields and Variables. Slide 2 Fields (Introduction) In ABAP, fields (or data objects) are named locations in memory Variables store.
110 E-1 Variables, Constants and Calculations(2) Chapter 3: Operations on variables, scope of a variable, formatting data Doing Arithmetic.
VB.NET 2008 Introduction to Variables Part 1. Overview.NET Languages –Source Code –Compiler –MSIL –CLR & Windows Variables –Data Types –Converting.
INTRODUCTION CHAPTER #1 Visual Basic.NET. VB.Net General features It is an object oriented language  In the past VB had objects but focus was not placed.
 Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. 
CIS 338: VB Variables Dr. Ralph D. Westfall April, 2011.
1 C#. 2 C#’s Family Tree C# inherits a rich programming legacy from C (1972) and C++ (1979). It is closely related to Java (1991).
B065: PROGRAMMING Variables 2. Starter  What is wrong with the following piece of code: Option Explicit Off Dim num1 as string Dim num2 as integer num1.
Basic Data Types อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา Chapter 4.
Introduction C# program is collection of classes Classes are collection of methods and some statements That statements contains tokens C# includes five.
Windows Programming Lecture 06. Data Types Classification Data types are classified in two categories that is, – those data types which stores decimal.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
Data Types. Visual Basic provides data type Single for storing single-precision floating-point numbers. Data type Double requires more memory to store.
Creating Database Objects
IS 350 Numeric Data Types.
Introduction to Programming Lecture 2
Chapter 2: Introduction to C++
An Application Uses Variables to Hold Information So It May Be Manipulated, Used to Manipulate Other Information, or Remembered for Later Use.
Java Primer 1: Types, Classes and Operators
Data Types, Arithmetic Operations
Understand Computer Storage and Data Types
Computing with C# and the .NET Framework
Chapter 2.
Data Types Imran Rashid CTO at ManiWeber Technologies.
B065: PROGRAMMING Variables 1.
Java Programming Language
B065: PROGRAMMING Variables 2.
Creating Database Objects
Presentation transcript:

.NET Data types

Introduction ٭ A "data type" is a class that is primarily used just to hold data. ٭ This is different from most other classes since they're primarily intended to 'do something', like access a database or format a page for example.

Data Types byte1 byteRange 0 to 255 Unsigned byte sbyte1 byteRange -128 to 127 Signed byte Short (sho) 2 bytesRange to Signed short ushort2 bytesRange 0 to Unsigned short

int (int) 4 bytesRange -2,147,483,647 to 2,147,483,647 Signed integer uint4 bytesRange 0 to 4,294,967,295 Unsigned integer long (lng) 8 bytesGreater than ±900,000 trillion Signed long int ulong8 bytesGreater than 18 million trillion Unsigned long int More Integer Data Types

Other Data Types single (sng) 4 bytesRange A number 6 digits past the decimal Float number double (dbl) 8 bytes Range A number 14 digits past the decimal Double precision decimal8 bytes Range A number 28 zeros long Fixed precision string (str)N/ARange N/AUnicode char2 bytes Range 0x0000 to 0xFFFF Unicode character Bool (bln)True or FalseBoolean

Block-Level Scope ٭ VB.NET introduces variables that only exist within blocks of code  Blocks are items such as For…Next, Do…Loop, and If Then…End If ٭ Variables are only visible within the block, but their lifetime is that of the whole procedure

Changes in Syntax ٭ Firstly the ‘Currency’ data type is no longer used in VB 6.0 ٭ Currency has been replaced with Decimal in VB.NET ٭ The Currency data type (64 bit) does not provide sufficient accuracy to avoid rounding errors, so Decimal (96 bit) was created as its own data type. ٭ Dim x As Currency is upgraded to: ٭ Dim x As Decimal

Long and Integer Data Types ٭ VB Long variables were stored as 32-bit numbers and Integer variables as 16-bit numbers ٭ VB.NET - Long variables are stored as 64-bit numbers, Integer variables are stored as 32-bit numbers, and Short variables are stored as 16-bit numbers.

No More Variant Data Type ٭ Variant data types are changed to Object due to keeping all the languages more similar. This is no longer the same as a pointer to an object. ٭ Dim x As Variant is upgraded to: ٭ Dim x As Object

Option Explicit ٭ In VB.BET the option is turned on by default for all new projects. ٭ When Option Explicit Off is used (not a good programming style), you can use any variable without first declaring it.

Option Strict On ٭ New Option in VB.NET ٭ When Option Strict is turned on, the compiler/editor does not allow implicit conversions from a wider data type to a narrower one, or between String and numeric data types ٭ CInt and CDec convert ٭ Limits erroneous numbers or run-time errors ٭ Place the line Option Strict On before the first line of code

Value vs. reference types ٭ Value types: ٭ variable represents a value ("bits") ٭ Reference types: ٭ variable represents a reference to a heap-based object ٭ actual data resides in the object int i; i = 10; 10 string s; s = "calico"; "calico"

How do you know which types are which? ٭ Memorization! ٭ Though it's pretty obvious based on past experience – primitive types like bool, int and double are values – remainder are reference types int i; string s; Customer c1, c2; i = 23; s = "a message"; c1 = null; c2 = new Customer(…);

Boxing and Unboxing ٭ When necessary, C# will auto-convert value object – value ==> object is called "boxing" – object ==> value is called "unboxing" int i, j; object obj; string s; i = 32; obj = i; // boxed copy! i = 19; j = (int) obj; // unboxed! s = j.ToString(); // boxed! s = 99.ToString(); // boxed!

User-defined reference types ٭ Classes! – for example, Customer class we worked with earlier… public class Customer { public string Name; // fields public int ID; public Customer(string name, int id) // constructor { this.Name = name; this.ID = id; } public override string ToString() // method { return "Customer: " + this.Name; } }

Working with reference types… ٭ Creating, assigning, and comparing: Customer c1, c2, c3; string s1, s2; c1 = new Customer("joe hummel", 36259); c2 = new Customer("marybeth lore", 55298); c3 = null; // c3 references no object c3 = c1; // c3 now references same obj as c1 if (c1 == null)... // do I ref an object? if (c1 == c2)... // compares references if (c1.Equals(c2))... // compares objects if (s1 == s2)... // exception: == overloaded to // compare string data

The End …… Thank You …..