---
title: "DataTypes"
content_type: tutorial
url: "https://learn.unity.com/course/beginner-scripting/tutorial/data-types?language=en"
language: en
container_type: course
container_title: "Beginner Scripting"
container_url: "https://learn.unity.com/course/beginner-scripting.md?language=en"
standalone_markdown_url: "https://learn.unity.com/tutorial/data-types.md?language=en"
previous_title: "Time"
previous_url: "https://learn.unity.com/course/beginner-scripting/tutorial/delta-time?language=en"
previous_markdown_url: "https://learn.unity.com/course/beginner-scripting/tutorial/delta-time.md?language=en"
difficulty: beginner
duration_minutes: 5
unity_version:
  - "2021.3"
supported_unity_versions:
  - name: "2021.3"
    url: "https://learn.unity.com/course/beginner-scripting/tutorial/data-types.md?language=en&version=2021.3"
  - name: "2019.3"
    url: "https://learn.unity.com/course/beginner-scripting/tutorial/data-types.md?language=en&version=2019.3"
  - name: "2019.2"
    url: "https://learn.unity.com/course/beginner-scripting/tutorial/data-types.md?language=en&version=2019.2"
  - name: "2019.1"
    url: "https://learn.unity.com/course/beginner-scripting/tutorial/data-types.md?language=en&version=2019.1"
  - name: "2018.4"
    url: "https://learn.unity.com/course/beginner-scripting/tutorial/data-types.md?language=en&version=2018.4"
  - name: "2018.3"
    url: "https://learn.unity.com/course/beginner-scripting/tutorial/data-types.md?language=en&version=2018.3"
  - name: "2018.2"
    url: "https://learn.unity.com/course/beginner-scripting/tutorial/data-types.md?language=en&version=2018.2"
  - name: "2018.1"
    url: "https://learn.unity.com/course/beginner-scripting/tutorial/data-types.md?language=en&version=2018.1"
  - name: "2017.4"
    url: "https://learn.unity.com/course/beginner-scripting/tutorial/data-types.md?language=en&version=2017.4"
  - name: "2017.3"
    url: "https://learn.unity.com/course/beginner-scripting/tutorial/data-types.md?language=en&version=2017.3"
  - name: "2017.2"
    url: "https://learn.unity.com/course/beginner-scripting/tutorial/data-types.md?language=en&version=2017.2"
  - name: "2017.1"
    url: "https://learn.unity.com/course/beginner-scripting/tutorial/data-types.md?language=en&version=2017.1"
  - name: "5.x"
    url: "https://learn.unity.com/course/beginner-scripting/tutorial/data-types.md?language=en&version=5.x"
  - name: "4.x"
    url: "https://learn.unity.com/course/beginner-scripting/tutorial/data-types.md?language=en&version=4.x"
last_updated: "2026-08-04T14:24:18.000Z"
---

# DataTypes

Learn how value and reference data types differ so you can reason more accurately about variables in C#.

Learn the important differences between Value and Reference data types, in order to better understand how variables work.

## 1. Data Types

[Video](http://www.youtube.com/watch?v=IVcx-tSxjys)

## **DatatypeScript**

```csharp
using UnityEngine;
using System.Collections;

public class DatatypeScript : MonoBehaviour 
{
    void Start () 
    {
        //Value type variable
        Vector3 pos = transform.position;
        pos = new Vector3(0, 2, 0);
        
        //Reference type variable
        Transform tran = transform;
        tran.position = new Vector3(0, 2, 0);
    }
}
```
