# ToString

> Returns a formatted string for this ray.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.5/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

## ToString()

Returns a formatted string for this ray.

```csharp
public override readonly string ToString()
```

### Returns

| Type                                                           | Description |
| -------------------------------------------------------------- | ----------- |
| [string](https://learn.microsoft.com/dotnet/api/system.string) |             |

### Remarks

Defaults to two digits displayed (format="F2"). For more information, see Microsoft's documentation on [Standard numeric format strings](https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings#FFormatString).

### Examples

```csharp
using UnityEngine;

public class Example : MonoBehaviour
{
    void Start()
    {
        Ray ray = new Ray(Vector3.zero, Vector3.zero);
        Debug.Log(ray.ToString()); // output displayed as: "Origin: (0.00, 0.00, 0.00), Dir: (0.00, 0.00, 0.00)"
    }
}
```

## ToString(string)

Returns a formatted string for this ray.

```csharp
public readonly string ToString(string format)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): A numeric format string.

### Returns

| Type                                                           | Description |
| -------------------------------------------------------------- | ----------- |
| [string](https://learn.microsoft.com/dotnet/api/system.string) |             |

### Remarks

Defaults to two digits displayed (format="F2"). For more information, see Microsoft's documentation on [Standard numeric format strings](https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings#FFormatString).

### Examples

```csharp
using UnityEngine;

public class Example : MonoBehaviour
{
    void Start()
    {
        Ray ray = new Ray(Vector3.zero, Vector3.zero);
        Debug.Log(ray.ToString()); // output displayed as: "Origin: (0.00, 0.00, 0.00), Dir: (0.00, 0.00, 0.00)"
    }
}
```

## ToString(string, IFormatProvider)

Returns a formatted string for this ray.

```csharp
public readonly string ToString(string format, IFormatProvider formatProvider)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): A numeric format string.**** (\[IFormatProvider]\(https\://learn.microsoft.com/dotnet/api/system.iformatprovider)): An object that specifies culture-specific formatting.

### Returns

| Type                                                           | Description |
| -------------------------------------------------------------- | ----------- |
| [string](https://learn.microsoft.com/dotnet/api/system.string) |             |

### Remarks

Defaults to two digits displayed (format="F2"). For more information, see Microsoft's documentation on [Standard numeric format strings](https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings#FFormatString).

### Examples

```csharp
using UnityEngine;

public class Example : MonoBehaviour
{
    void Start()
    {
        Ray ray = new Ray(Vector3.zero, Vector3.zero);
        Debug.Log(ray.ToString()); // output displayed as: "Origin: (0.00, 0.00, 0.00), Dir: (0.00, 0.00, 0.00)"
    }
}
```
