Changing a material.color.a

I am trying to change a materials alpha on runtime.

I have googled and a lot of answers gave me the following code:

using UnityEngine;

public class Stuff : MonoBehaviour {

	public Rigidbody Body { get; private set; }
	void Awake () {
		Body = GetComponent<Rigidbody>();

	void Update () {
            //answer I found, intend to change the 0.5f when it works.
		Color c = GetComponent<MeshRenderer>().material.color.a = 0.5f;

However, I keep getting the following error:
Cannot modify the return value of 'Material.color' because it is not a variable

Try storing the value for the color in a temporary variable like so :

 Color tempcolor;
     void Update () {
             tempcolor = GetComponent<MeshRenderer>().material.color;
    tempcolor.a = .5f;
    GetComponent<MeshRenderer>().material.color = tempcolor;

The reason that

GetComponent<MeshRenderer>.color.a = .5f;

wont work is because the left hand side is a copy of the color’s alpha component then i’m trying to overwrite it with .5f which is a useless operation.

also make sure the object’s rendering mode is transparent.