SlideShare a Scribd company logo
DATA TYPES, VARIABLES AND
CONSTANT
ITEC102: Fundamentals of Programming
Data Types
A DataType is a classification that specifies which type
of value a variable has and what type of mathematical,
relational or logical operations can be applied to it
without causing an error.
For example, a string is a data type that is used to
classify text and an integer is a data type used to
classify whole numbers.
Primitive and Non-Primitive
C# is a strongly typed language which means that
variables must be explicitly defined.
The compiler will throw an error if a value assigned or
being assigned is not the data type specified.
An example of this is a variable assigned a number
cannot hold text later on in the program.
Also, a variable defined as an integer cannot be assigned
a string.
Strongly typed
A strongly-typed programming language is one in which
each type of data (such as integer, character,
hexadecimal, packed decimal, and so forth) is
predefined as part of the programming language and all
constants or variables defined for a given program must
be described with one of the data types.
https://whatis.techtarget.com/definition/strongly-typed
Data Types, Variables, and Constants in C# Programming
Primitive (Value Type)
C# primitives are also called value types and
predefined in the .NET framework.
Primitive types can be assigned a value directly.
The value assigned is stored on the stack as opposed to
the heap.
Primitive (Value Type)
A Stack is used for static memory allocation and Heap
for dynamic memory allocation, both stored in the
computer's RAM.
Variables allocated on the stack are stored directly to
the memory and access to this memory is very fast, and
its allocation is dealt with when the program is
compiled.
Data Types, Variables, and Constants in C# Programming
Primitive (Value Type)
While value types are stored generally in
the stack, reference types are stored in the
managed heap.
A value type derives from System.ValueType and
contains the data inside its own memory allocation.
In other words, variables or objects or value types have
their own copy of the data.
Available value types in C# 2010
Type Represents Range DefaultValue
bool Boolean value True or False False
byte 8-bit unsigned integer 0 to 255 0
char 16-bit Unicode character U +0000 to U +ffff ‘0’
decimal
128-bit precise decimal values with 28-29
significant digits
(-7.9 x 1028 to 7.9 x 1028) / 100 to 28 0.0M
double 64-bit double-precision floating point type (+/-)5.0 x 10-324 to (+/-)1.7 x 10308 0.0D
float 32-bit single-precision floating point type -3.4 x 1038 to + 3.4 x 1038 0.0F
Available value types in C# 2010
int 32-bit signed integer type -2,147,483,648 to 2,147,483,647 0
long 64-bit signed integer type
-923,372,036,854,775,808 to
9,223,372,036,854,775,807
0L
sbyte 8-bit signed integer type -128 to 127 0
short 16-bit signed integer type -32,768 to 32,767 0
uint 32-bit unsigned integer type 0 to 4,294,967,295 0
ulong 64-bit unsigned integer type 0 to 18,446,744,073,709,551,615 0
ushort 16-bit unsigned integer type 0 to 65,535 0
Non-primitive (Reference Type)
The reference types do not contain the actual data stored in
a variable, but they contain a reference to the variables.
In other words, they refer to a memory location.
Using multiple variables, the reference types can refer to a
memory location.
If the data in the memory location is changed by one of the
variables, the other variable automatically reflects this
change in value.
Object Type
The ObjectType is the ultimate base class for all data
types in C# CommonType System (CTS).
The object types can be assigned values of any other
types, value types, reference types, predefined or user-
defined types.
However, before assigning values, it needs type
conversion.
Boxing / Unboxing
When a value type is converted to object type, it is
called boxing and on the other hand, when an object
type is converted to a value type, it is called unboxing.
Boxing Conversion
Unboxing Conversion
Dynamic Type
You can store any type of value in the dynamic data type
variable.Type checking for these types of variables
takes place at run-time.
Syntax for declaring a dynamic type is:
dynamic <variable_name> = value;
For example,
dynamic d = 20;
String Type
The StringType allows you to assign any string values to
a variable.The string type is an alias for the
System.String class. It is derived from object type.The
value for a string type can be assigned using string
literals in two forms: quoted and @quoted.
For example: String str = "Hello Universe";
@"Hello Universe";
Pointer Type
Pointer type variables store the memory address of
another type. Pointers in C# have the same capabilities
as the pointers in C or C++.
Syntax for declaring a pointer type is:
type* identifier;
For example, char* cptr;
int* iptr;
Variables
Variables are used to store information to
be referenced and used inside a program.
Each variable has a specific type, which
determines the size and layout of the
variable's memory, the range of values that
can be stored within that memory, and the
set of operations that can be applied to the
variable.
Variables
Type Example
Integral types
sbyte, byte, short, ushort, int, uint, long, ulong, and
char
Floating point types float and double
Decimal types decimal
Boolean types true or false values, as assigned
Nullable types Nullable data types
Defining Variables
Syntax for variable definition in C# is:
<data_type> <variable_list>;
Here, data_type must be a valid C# data type including
char, int, float, double, or any user-defined data type,
and variable_list may consist of one or more identifier
names separated by commas.
Some valid variable definitions
int i, j, k;
char c, ch;
float f, salary;
double d;
Variable Names
To use variables in your C# programs, you must know
how to create variable names.
In C#, variable names must adhere to the following
rules:
Variable Names
The name can contain letters, digits, and the underscore
character (_).
The first character of the name must be a letter.The
underscore is also a legal first character, but its use is not
recommended at the beginning of a name.An underscore
is often used with special commands, and it's sometimes
hard to read.
Variable Names
Case matters (that is, upper- and lowercase letters). C# is
case-sensitive; thus, the names count and Count refer to
two different variables.
C# keywords can't be used as variable names. Recall that a
keyword is a word that is part of the C# language.
valid and invalid C# variable names:
Variable
Name
Legality
Percent Legal
y2x5__w7h3 Legal
yearly_cost Legal
_2010_tax Legal, but not advised
valid and invalid C# variable names:
Variable Name Legality
Percent Legal
y2x5__w7h3 Legal
yearly_cost Legal
_2010_tax Legal, but not advised
checking#account Illegal; contains the illegal character #
double Illegal; is a C keyword
9byte Illegal; first character is a digit
Initializing Variables
Variables are initialized (assigned a value) with an equal
sign followed by a constant expression.The general
form of initialization is:
variable_name = value;
You can initialize a variable at the time of definition as:
int i = 100;
Initializing Variables
Variables can be initialized in their declaration.The
initializer consists of an equal sign followed by a
constant expression as:
<data_type> <variable_name> = value;
Initializing Variables
Some examples are:
int d = 3, f = 5; /* initializing d and f. */
byte z = 22; /* initializes z. */
double pi = 3.14159; /* declares an approximation of pi. */
char x = 'x'; /* the variable x has the value 'x'. */
using System;
namespaceVariableDefinition
{
class Program
{
static void Main(string[] args)
{
short a;
int b;
double c;
/* actual initialization */
a = 10;
b = 20;
c = a + b;
Console.WriteLine("a = {0}, b = {1}, c = {2}", a, b, c);
Console.ReadLine();
}
}
}
This example
uses various
types of
variables
When the above code is
compiled and executed, it
produces the following result:
a = 10, b = 20, c = 30
Accepting Value from User
The simplest method to get input from the user is by
using the ReadLine() method of the Console class.
However, Read() and ReadKey() are also available for
getting input from the user.They are also included
in Console class.
string testString;
Console.Write("Enter a string - ");
testString = Console.ReadLine();
Console.WriteLine("You entered '{0}'", testString);
Difference between ReadLine(), Read()
and ReadKey() method:
ReadLine(): reads the next line of input from the
standard input stream. It returns the same string.
Read(): reads the next character from the standard
input stream. It returns the ascii value of the character.
ReadKey(): obtains the next key pressed by user.This
method is usually used to hold the screen until user
press a key.
Lvalue and Rvalue in C#
There are two kinds of expressions in C#:
1. lvalue: An expression that is an lvalue may appear as
either the left-hand or right-hand side of an
assignment.
2. rvalue: An expression that is an rvalue may appear on
the right- but not left-hand side of an assignment.
Lvalue and Rvalue in C#
Following is a valid C# statement:
int g = 20;
But following is not a valid statement and would
generate compile-time error:
10 = 20;
Constants
Constants are immutable values which are known at
compile time and do not change for the life of the
program.
Constants are declared with the const modifier.
Only the C# built-in types (excluding System.Object)
may be declared as “const”
Integer Literal
An integer literal can be a decimal, octal, or hexadecimal
constant. A prefix specifies the base or radix: 0x or 0X for
hexadecimal, 0 for octal, and no prefix id for decimal.
An integer literal can also have a suffix that is a
combination of U and L, for unsigned and long,
respectively.The suffix can be uppercase or
lowercase and can be in any order.
Integer Literal
Here are some examples of integer literals:
212 /* Legal */
215u /* Legal */
0xFeeL /* Legal */
078 /* Illegal: 8 is not an octal digit */
032UU /* Illegal: cannot repeat a suffix */
Integer Literal
Following are other examples of various types of Integer
literals:
85 /* decimal */
0213 /* octal */
0x4b /* hexadecimal */
30 /* int */
30u /* unsigned int */
30l /* long */
30ul /* unsigned long */
Floating-Point Literal
A floating-point literal has an integer part, a decimal point, a
fractional part, and an exponent part.You can represent
floating point literals either in decimal form or exponential
form.
Here are some examples of floating-point literals:
 3.14159 /* Legal */
314159E-5L /* Legal */
510E /* Illegal: incomplete exponent */
210f /* Illegal: no decimal or exponent */
.e55 /* Illegal: missing integer or fraction */
escape sequence codes
Escape sequence Meaning
  character
' ' character
" " character
? ? character
a Alert or bell
b Backspace
f Form feed
n Newline
r Carriage return
t Horizontal tab
v Vertical tab
ooo Octal number of one to three digits
xhh . . . Hexadecimal number of one or more digits

More Related Content

PPTX
What is dotnet (.NET) ?
PDF
PPTX
Requirements analysis and modeling
PPT
PPT
Chapter12 designing databases
PPTX
C# 101: Intro to Programming with C#
DOCX
CBLM - Set Up Computer Network (CSS)
What is dotnet (.NET) ?
Requirements analysis and modeling
Chapter12 designing databases
C# 101: Intro to Programming with C#
CBLM - Set Up Computer Network (CSS)

What's hot (20)

PPTX
Data types in c++
PPT
Introduction To C#
PPTX
Java Data Types
PPTX
Operators in java
PPTX
Array in c#
PPTX
Css selectors
PPTX
Chapter 1
PDF
JavaScript - Chapter 6 - Basic Functions
PPT
C# Basics
PPT
Introduction to JavaScript
PPTX
Strings in Java
PPTX
Fundamentals of c programming
PPSX
Javascript variables and datatypes
PPTX
Exceptions in Java
PPTX
C tokens
PPTX
Control structures in java
PPTX
C++ string
PPT
Operator Overloading
PPT
C#.NET
PPTX
Delegates and events in C#
Data types in c++
Introduction To C#
Java Data Types
Operators in java
Array in c#
Css selectors
Chapter 1
JavaScript - Chapter 6 - Basic Functions
C# Basics
Introduction to JavaScript
Strings in Java
Fundamentals of c programming
Javascript variables and datatypes
Exceptions in Java
C tokens
Control structures in java
C++ string
Operator Overloading
C#.NET
Delegates and events in C#
Ad

Similar to Data Types, Variables, and Constants in C# Programming (20)

DOCX
Unit 1 question and answer
PDF
PSPC--UNIT-2.pdf
DOC
Data type
PDF
434090527-C-Cheat-Sheet. pdf C# program
PDF
CSharpCheatSheetV1.pdf
PPTX
unit 1 (1).pptx
PDF
Learn C# Programming - Variables & Constants
DOCX
Dot net programming concept
PPT
Data Handling
PPTX
Notes(1).pptx
PPTX
Object Oriented Programming with C++
PPT
C the basic concepts
PPTX
LEARN C# PROGRAMMING WITH GMT
DOCX
C programming tutorial
PPTX
PPTX
Chapter 2 c#
PPT
5-Lec - Datatypes.ppt
PPTX
Programming_in_C_language_Unit5.pptx course ATOT
PPTX
C programming Training in Ambala ! Batra Computer Centre
Unit 1 question and answer
PSPC--UNIT-2.pdf
Data type
434090527-C-Cheat-Sheet. pdf C# program
CSharpCheatSheetV1.pdf
unit 1 (1).pptx
Learn C# Programming - Variables & Constants
Dot net programming concept
Data Handling
Notes(1).pptx
Object Oriented Programming with C++
C the basic concepts
LEARN C# PROGRAMMING WITH GMT
C programming tutorial
Chapter 2 c#
5-Lec - Datatypes.ppt
Programming_in_C_language_Unit5.pptx course ATOT
C programming Training in Ambala ! Batra Computer Centre
Ad

Recently uploaded (20)

PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Cloud computing and distributed systems.
PDF
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
cuic standard and advanced reporting.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Empathic Computing: Creating Shared Understanding
20250228 LYD VKU AI Blended-Learning.pptx
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Cloud computing and distributed systems.
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
Understanding_Digital_Forensics_Presentation.pptx
Spectral efficient network and resource selection model in 5G networks
Reach Out and Touch Someone: Haptics and Empathic Computing
cuic standard and advanced reporting.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Review of recent advances in non-invasive hemoglobin estimation
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Empathic Computing: Creating Shared Understanding

Data Types, Variables, and Constants in C# Programming

  • 1. DATA TYPES, VARIABLES AND CONSTANT ITEC102: Fundamentals of Programming
  • 2. Data Types A DataType is a classification that specifies which type of value a variable has and what type of mathematical, relational or logical operations can be applied to it without causing an error. For example, a string is a data type that is used to classify text and an integer is a data type used to classify whole numbers.
  • 3. Primitive and Non-Primitive C# is a strongly typed language which means that variables must be explicitly defined. The compiler will throw an error if a value assigned or being assigned is not the data type specified. An example of this is a variable assigned a number cannot hold text later on in the program. Also, a variable defined as an integer cannot be assigned a string.
  • 4. Strongly typed A strongly-typed programming language is one in which each type of data (such as integer, character, hexadecimal, packed decimal, and so forth) is predefined as part of the programming language and all constants or variables defined for a given program must be described with one of the data types. https://whatis.techtarget.com/definition/strongly-typed
  • 6. Primitive (Value Type) C# primitives are also called value types and predefined in the .NET framework. Primitive types can be assigned a value directly. The value assigned is stored on the stack as opposed to the heap.
  • 7. Primitive (Value Type) A Stack is used for static memory allocation and Heap for dynamic memory allocation, both stored in the computer's RAM. Variables allocated on the stack are stored directly to the memory and access to this memory is very fast, and its allocation is dealt with when the program is compiled.
  • 9. Primitive (Value Type) While value types are stored generally in the stack, reference types are stored in the managed heap. A value type derives from System.ValueType and contains the data inside its own memory allocation. In other words, variables or objects or value types have their own copy of the data.
  • 10. Available value types in C# 2010 Type Represents Range DefaultValue bool Boolean value True or False False byte 8-bit unsigned integer 0 to 255 0 char 16-bit Unicode character U +0000 to U +ffff ‘0’ decimal 128-bit precise decimal values with 28-29 significant digits (-7.9 x 1028 to 7.9 x 1028) / 100 to 28 0.0M double 64-bit double-precision floating point type (+/-)5.0 x 10-324 to (+/-)1.7 x 10308 0.0D float 32-bit single-precision floating point type -3.4 x 1038 to + 3.4 x 1038 0.0F
  • 11. Available value types in C# 2010 int 32-bit signed integer type -2,147,483,648 to 2,147,483,647 0 long 64-bit signed integer type -923,372,036,854,775,808 to 9,223,372,036,854,775,807 0L sbyte 8-bit signed integer type -128 to 127 0 short 16-bit signed integer type -32,768 to 32,767 0 uint 32-bit unsigned integer type 0 to 4,294,967,295 0 ulong 64-bit unsigned integer type 0 to 18,446,744,073,709,551,615 0 ushort 16-bit unsigned integer type 0 to 65,535 0
  • 12. Non-primitive (Reference Type) The reference types do not contain the actual data stored in a variable, but they contain a reference to the variables. In other words, they refer to a memory location. Using multiple variables, the reference types can refer to a memory location. If the data in the memory location is changed by one of the variables, the other variable automatically reflects this change in value.
  • 13. Object Type The ObjectType is the ultimate base class for all data types in C# CommonType System (CTS). The object types can be assigned values of any other types, value types, reference types, predefined or user- defined types. However, before assigning values, it needs type conversion.
  • 14. Boxing / Unboxing When a value type is converted to object type, it is called boxing and on the other hand, when an object type is converted to a value type, it is called unboxing.
  • 17. Dynamic Type You can store any type of value in the dynamic data type variable.Type checking for these types of variables takes place at run-time. Syntax for declaring a dynamic type is: dynamic <variable_name> = value; For example, dynamic d = 20;
  • 18. String Type The StringType allows you to assign any string values to a variable.The string type is an alias for the System.String class. It is derived from object type.The value for a string type can be assigned using string literals in two forms: quoted and @quoted. For example: String str = "Hello Universe"; @"Hello Universe";
  • 19. Pointer Type Pointer type variables store the memory address of another type. Pointers in C# have the same capabilities as the pointers in C or C++. Syntax for declaring a pointer type is: type* identifier; For example, char* cptr; int* iptr;
  • 20. Variables Variables are used to store information to be referenced and used inside a program. Each variable has a specific type, which determines the size and layout of the variable's memory, the range of values that can be stored within that memory, and the set of operations that can be applied to the variable.
  • 21. Variables Type Example Integral types sbyte, byte, short, ushort, int, uint, long, ulong, and char Floating point types float and double Decimal types decimal Boolean types true or false values, as assigned Nullable types Nullable data types
  • 22. Defining Variables Syntax for variable definition in C# is: <data_type> <variable_list>; Here, data_type must be a valid C# data type including char, int, float, double, or any user-defined data type, and variable_list may consist of one or more identifier names separated by commas. Some valid variable definitions int i, j, k; char c, ch; float f, salary; double d;
  • 23. Variable Names To use variables in your C# programs, you must know how to create variable names. In C#, variable names must adhere to the following rules:
  • 24. Variable Names The name can contain letters, digits, and the underscore character (_). The first character of the name must be a letter.The underscore is also a legal first character, but its use is not recommended at the beginning of a name.An underscore is often used with special commands, and it's sometimes hard to read.
  • 25. Variable Names Case matters (that is, upper- and lowercase letters). C# is case-sensitive; thus, the names count and Count refer to two different variables. C# keywords can't be used as variable names. Recall that a keyword is a word that is part of the C# language.
  • 26. valid and invalid C# variable names: Variable Name Legality Percent Legal y2x5__w7h3 Legal yearly_cost Legal _2010_tax Legal, but not advised
  • 27. valid and invalid C# variable names: Variable Name Legality Percent Legal y2x5__w7h3 Legal yearly_cost Legal _2010_tax Legal, but not advised checking#account Illegal; contains the illegal character # double Illegal; is a C keyword 9byte Illegal; first character is a digit
  • 28. Initializing Variables Variables are initialized (assigned a value) with an equal sign followed by a constant expression.The general form of initialization is: variable_name = value; You can initialize a variable at the time of definition as: int i = 100;
  • 29. Initializing Variables Variables can be initialized in their declaration.The initializer consists of an equal sign followed by a constant expression as: <data_type> <variable_name> = value;
  • 30. Initializing Variables Some examples are: int d = 3, f = 5; /* initializing d and f. */ byte z = 22; /* initializes z. */ double pi = 3.14159; /* declares an approximation of pi. */ char x = 'x'; /* the variable x has the value 'x'. */
  • 31. using System; namespaceVariableDefinition { class Program { static void Main(string[] args) { short a; int b; double c; /* actual initialization */ a = 10; b = 20; c = a + b; Console.WriteLine("a = {0}, b = {1}, c = {2}", a, b, c); Console.ReadLine(); } } } This example uses various types of variables When the above code is compiled and executed, it produces the following result: a = 10, b = 20, c = 30
  • 32. Accepting Value from User The simplest method to get input from the user is by using the ReadLine() method of the Console class. However, Read() and ReadKey() are also available for getting input from the user.They are also included in Console class. string testString; Console.Write("Enter a string - "); testString = Console.ReadLine(); Console.WriteLine("You entered '{0}'", testString);
  • 33. Difference between ReadLine(), Read() and ReadKey() method: ReadLine(): reads the next line of input from the standard input stream. It returns the same string. Read(): reads the next character from the standard input stream. It returns the ascii value of the character. ReadKey(): obtains the next key pressed by user.This method is usually used to hold the screen until user press a key.
  • 34. Lvalue and Rvalue in C# There are two kinds of expressions in C#: 1. lvalue: An expression that is an lvalue may appear as either the left-hand or right-hand side of an assignment. 2. rvalue: An expression that is an rvalue may appear on the right- but not left-hand side of an assignment.
  • 35. Lvalue and Rvalue in C# Following is a valid C# statement: int g = 20; But following is not a valid statement and would generate compile-time error: 10 = 20;
  • 36. Constants Constants are immutable values which are known at compile time and do not change for the life of the program. Constants are declared with the const modifier. Only the C# built-in types (excluding System.Object) may be declared as “const”
  • 37. Integer Literal An integer literal can be a decimal, octal, or hexadecimal constant. A prefix specifies the base or radix: 0x or 0X for hexadecimal, 0 for octal, and no prefix id for decimal. An integer literal can also have a suffix that is a combination of U and L, for unsigned and long, respectively.The suffix can be uppercase or lowercase and can be in any order.
  • 38. Integer Literal Here are some examples of integer literals: 212 /* Legal */ 215u /* Legal */ 0xFeeL /* Legal */ 078 /* Illegal: 8 is not an octal digit */ 032UU /* Illegal: cannot repeat a suffix */
  • 39. Integer Literal Following are other examples of various types of Integer literals: 85 /* decimal */ 0213 /* octal */ 0x4b /* hexadecimal */ 30 /* int */ 30u /* unsigned int */ 30l /* long */ 30ul /* unsigned long */
  • 40. Floating-Point Literal A floating-point literal has an integer part, a decimal point, a fractional part, and an exponent part.You can represent floating point literals either in decimal form or exponential form. Here are some examples of floating-point literals:  3.14159 /* Legal */ 314159E-5L /* Legal */ 510E /* Illegal: incomplete exponent */ 210f /* Illegal: no decimal or exponent */ .e55 /* Illegal: missing integer or fraction */
  • 41. escape sequence codes Escape sequence Meaning character ' ' character " " character ? ? character a Alert or bell b Backspace f Form feed n Newline r Carriage return t Horizontal tab v Vertical tab ooo Octal number of one to three digits xhh . . . Hexadecimal number of one or more digits

Editor's Notes

  • #5: Certain operations may be allowable only with certain data types. The language compiler enforces the data typing and use compliance. An advantage of strong data typing is that it imposes a rigorous set of rules on a programmer and thus guarantees a certain consistency of results. A disadvantage is that it prevents the programmer from inventing a data type not anticipated by the developers of the programming language and it limits how "creative" one can be in using a given data type.
  • #16: It is also possible to perform the boxing explicitly as in the following example, but explicit boxing is never required: int i = 123; object o = (object)i;  // explicit boxing
  • #18: Dynamic types are similar to object types except that type checking for object type variables takes place at compile time, whereas that for the dynamic type variables takes place at run time.
  • #19: The user-defined reference types are: class, interface, or delegate.
  • #21: Each variable has a specific type, which determines the size and layout of the variable's memory, the range of values that can be stored within that memory, and the set of operations that can be applied to the variable.
  • #29: It is a good programming practice to initialize variables properly, otherwise sometimes program may produce unexpected result.
  • #35: Variables are lvalues and hence they may appear on the left-hand side of an assignment. Numeric literals are rvalues and hence they may not be assigned and cannot appear on the left-hand side.
  • #41: While representing in decimal form, you must include the decimal point, the exponent, or both; and while representing using exponential form you must include the integer part, the fractional part, or both. The signed exponent is introduced by e or E.