0% found this document useful (0 votes)
7 views

Data Types, Variables, and Constants Integer Data Types

This document discusses integer data types in C#, including byte, short, int, and long which have different numbers of bits in memory. It notes that adding 1 to an int variable with a value of 1 will result in 2, while adding 1 to an int variable with a maximum value will overflow and result in the minimum int value. The document also distinguishes between value types and reference types before covering integer data types.

Uploaded by

Luca Kab
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Data Types, Variables, and Constants Integer Data Types

This document discusses integer data types in C#, including byte, short, int, and long which have different numbers of bits in memory. It notes that adding 1 to an int variable with a value of 1 will result in 2, while adding 1 to an int variable with a maximum value will overflow and result in the minimum int value. The document also distinguishes between value types and reference types before covering integer data types.

Uploaded by

Luca Kab
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Module 3

Data Types, Variables, and


Constants

Lecture
Integer Data Types

Module 3 Learning Objectives


In this lecture, well discuss the various data types
we use to represent integers in C#
Before we do, we make an important distinction
between value types and reference types

Integers (no fractions or
decimals)
0, 42, -11
byt e, shor t , i nt ,
l ong
Different number of
bits in memory for
each type
What does that tell us?
Operations are mostly as
youd expect (except for /)
In-Lecture Quiz

In C#, if we add 1 to an i nt variable that currently has
a value of 1, the new value of the variable is

A: 5
B: 12
C: 2
D: -0


In-Lecture Quiz

In C#, if we add 1 to an i nt variable that currently has
a value of 2,147,483,647, the new value of the variable
is

A: 2,147,483,648
B: -2,147,483,648
C: 42
D: 2



Recap
For the value types, the contents of the memory
location are interpreted as the value of the variable
C# provides a variety of data types for representing
integers
Next Time
Real numbers

You might also like