unity ui change sprite

C#
// TO change the sprite of an UI image, se below
GameObject.GetComponent<Image>().sprite = sprite;
Source

Also in C#: