how can i swap textures?

i’d like to be able to swap out the texture of an object for a png in my project. how would i go about doing that?

http://unity3d.com/support/documentation/ScriptReference/Material-mainTexture.html has an example. A simpler one is:

public Texture2D catPic; // click and select a texture
renderer.material.mainTexture = catPic;