How can I get the width and height of a texture in pixels?

How can I assign a texture to Texture2D in runtime?