Change the sprite of a UI Canvas image in Unity C#

Change the sprite of a UI Canvas image in Unity C#

// Declare an Image.
Image c_Image;

// Set the new Sprite in the Inspector.
[SerializeField] private Sprite new_Sprite;

void Start()
{
// Get the Image Component from the GameObject.
c_Image = GetComponent();
}

// public function to call and change the sprite.
public void ChangeSpriteOnUIImage()
{
// Getting the Sprite from the Image Component and sign the new one.
c_Image.sprite = new_Sprite;
}