change sprite of gameobject unity

C#
gameObjectName.GetComponent<SpriteRenderer>().sprite = spriteName;
Source

Also in C#: