How do you change the color of a simple cube in Unity 5.0?

I’ve seen all these videos and they are telling me do:

gameObject.renderer.material.color

But the problem is that the material part doesn’t show up. Then I came across the fact that this line of code is deprecated, so now I’m stuck. I found something that should have helped:

var rend = GetComponent();

But now what do I do? I just want to change the color of a cube, so please don’t make anything really complicated I’m just a beginner.

gameObject.GetComponent().material.color = Color.red;

Thinking about Frames per Second I would recommend using .Sharedmaterial.color etc