How to print variable? (C#)

I want to print a variable “coin” by text(UI). How to make it?

First you definitely need a Canvas and a Text gameObject. So lets call the Text “VariableText”.
Secondly you need to set up a reference to the VariableText to alter its content.

public Text variableText;

Then you can change variableText.text to the text that you wanna to display. Something like this :

variableText.text = "My Coins: " + coins;

Just for integrity let me post a full C# script:

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class CoinShower : MonoBehaviour
{
    public Text variableText;
    public int coins;

    public void ShowCoins ()
    {
        variableText.text = "My Coins: " + coins;
    }
}