Problems setting color in C#

I’m trying to make a wall in c#. I want to set differents colors for each cube, but when i run it, all cubes are white. here is my code:

public class Wall : MonoBehaviour
{
    // Use this for initialization
    void Awake()
    {
        for (int i = 0; i < 5; i++)
            for (int j = 0; j < 5; j++)
            {
                GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                cube.transform.position = new Vector3(i, j, 0);
                cube.renderer.material.color = getRandColor();
            }
    }

    private Color getRandColor()
    {
        print(Random.value);
        int r = (int)(Random.value * 255);
        int g = (int)(Random.value * 255);
        int b = (int)(Random.value * 255);
        print(r + "---" + g + "---" + b + "---");
        return new Color(r, g, b);
    }

    // Update is called once per frame
    void Update()
    {

    }
}

That’s because Colors constructor accept floats in the range of 0 to 1 where you feed integers in the range of 0 to 255.

This should do it.

private Color getRandColor(){
    float r = Random.value;
    float g = Random.value;
    float b = Random.value;
    return new Color(r,g,b);
}

As syclamoth mentioned before he deleted his post (which I think was a more informative post), the reason you are getting white blocks is that the values 1-255 will be clamped to 1. So there’s 1 in 256 chance per channel to produce another color than white if you are using integers in your range.