<div class="meta" robots="noindex">

</div>

DataType

# Auto

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<div class="warning">

<div class="title">

Warning

</div>

This item was deprecated in version 2021r1. Please use `Variant</api/data_types/variant>` as a replacement.

</div>

## Description

The <span class="title-ref">Auto</span> type can store and retrieve any type value, but cannot convert to other types.

## Notes

Once a value is placed into an <span class="title-ref">Auto</span> variable, it is treated as if it is that type of the value. For example, if you assign an Integer to an <span class="title-ref">Auto</span> variable, you can not later use it as a Text. You'll have to first assign it to an Integer and then convert it to a Text using intVal.ToText. You can use Introspection to check the type of the value contained in an <span class="title-ref">Auto</span> variable as shown in the sample code below. You can assign a value of a different type to an <span class="title-ref">Auto</span> that already had a value.

## Sample code

Some <span class="title-ref">Auto</span> examples:

``` xojo
' Add an Auto containing an integer
Var num As Auto
num = 42

Var sum As Integer
sum = num + 10

' Display an Auto containing an integer
Var numInt As Integer = num
Var output As Text
output = numInt.ToText ' output contains "42"

' Convert an Auto containing a Double to Text
Var num As Auto = 5.5
Var t As Text = CType(num, Double).ToText
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Check the type of an <span class="title-ref">Auto</span> variable:

``` xojo
Var autoVar As Auto = 42
Var info As Xojo.Introspection.TypeInfo
info = Xojo.Introspection.GetType(autoVar)

Label1.Text = "Type: " + info.Name ' Displays Int32
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Compare type of an <span class="title-ref">Auto</span> variable:

``` xojo
Var a As Auto
Var t As Text = "Hello"
a = t
If Xojo.Introspection.GetType(a) = GetTypeInfo(Text) Then
  ' It's text
End If
```

## Compatibility

All project types on all supported operating systems.

## See also

`String</api/data_types/string>`
