How do I convert a texture2D to a material?

How do I convert a texture2D to a material?

Right click on your Texture in Content → Create material from this Texture

I want do it in blueprint or C++programming

You should consider creating a material, with TextureObjectParameter, and then use MID(Material Instance Dynamic)
and pass required Texture2D as parameter to your material instance, that was created at runtime.

If that resolved your question, kindly mark it as answered and consider upvoting correct answer. Thanks.

How to convert texture 2D to Material?