How to create a Texture2D from a sprite asset

I need to change the sprite property of a SpriteRenderer component programmatically. The Sprite.Create() function takes a Texture2D object, which is the sprite image. I have a sprite sheet that is split into sprites automatically by Unity. How do I make a Texture2D object from one of these sprites?

Check out - Convert Sprite Image to Texture - Unity Answers

Just use

sprite.texture