How to create a sprite programtically

hi guys,

i am new to unity and facing some problems.
i am currently working on a game where i want to create a sprite at runtime i.e programatically.
i googled a lot and did all sort of try but find no solution to it.

please guys help me with that.
thanks in advance…

If you need to load a sprite from an image file at runtime, put the file into Resources folder, and

GetComponent<SpriteRenderer>().sprite = Resources.Load<Sprite>("enemy");