Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Data Types in C#Data Types in C#
Made By;
Malik Zeeshan Ahmed
C# Data TypesC# Data Types
 Value types
Pre-defined:
◦ int, uint, float, etc.
User-defined:
◦ Structures and Enumerations...
C# Value vs. Reference
• Value Types “directly contain”
the variable data.
– Example: int, float, enum,
struct...
• Refere...
class ValueType
• ValueType is a class that inherits directly from object
– You cannot inherit from ValueType
• ValueType ...
Value typeValue type
 value-types inherit directly from ValueType
◦ Built in types(bool,int,…etc)
◦ enum types
◦ struct t...
value-type Hierarchy
value-type
struct-type enum-type
type-namesimple-type
numeric-type bool
type-name
floating-point-type...
Reference Types
• Classes
– object (System.Object)
– string
– user-defined classes
• Interfaces
• Arrays
• Delegates
– del...
Reference-type Hierarchy
reference-type
array-typeinterface-typeclass-type
type-name object
delegate-type
string
Reference-type Hierarchy
reference-type
array-typeinterface-typeclass-type
type-name object
delegate-type
string
7.data types in c#
Upcoming SlideShare
Loading in …5
×

7.data types in c#

1,159 views

Published on

Published in: Technology, Sports
  • Be the first to comment

7.data types in c#

  1. 1. Data Types in C#Data Types in C# Made By; Malik Zeeshan Ahmed
  2. 2. C# Data TypesC# Data Types  Value types Pre-defined: ◦ int, uint, float, etc. User-defined: ◦ Structures and Enumerations  Reference types Pre-defined: ◦ Objects ◦ Strings User-defined: ◦ Classes ◦ Arrays ◦ Delegates ◦ Interfaces  Everything inherits from System.Object
  3. 3. C# Value vs. Reference • Value Types “directly contain” the variable data. – Example: int, float, enum, struct... • Reference Types contain a reference to the data Memory int x int y myObject Reference Type Memory ref0 ref1 Value TypeReference Type Memory ref0 ref1 myObject Memory ref0 ref1 Reference Type myObject Memory ref0 ref1 Reference Type myObject Memory ref0 ref1 Reference Type Memory ref0 ref1 myObject Reference Type Memory ref0 ref1
  4. 4. class ValueType • ValueType is a class that inherits directly from object – You cannot inherit from ValueType • ValueType overrides System.Object methods so they make sense
  5. 5. Value typeValue type  value-types inherit directly from ValueType ◦ Built in types(bool,int,…etc) ◦ enum types ◦ struct types  All value-types are sealed  value-types cannot be null  Assignment of a value-type results in a copy of the variable
  6. 6. value-type Hierarchy value-type struct-type enum-type type-namesimple-type numeric-type bool type-name floating-point-typeintegral-type decimal
  7. 7. Reference Types • Classes – object (System.Object) – string – user-defined classes • Interfaces • Arrays • Delegates – delegate (System.Delegate)
  8. 8. Reference-type Hierarchy reference-type array-typeinterface-typeclass-type type-name object delegate-type string
  9. 9. Reference-type Hierarchy reference-type array-typeinterface-typeclass-type type-name object delegate-type string

×