Getting value of material and applying it to another material through code

Hi, I’ve been changing the color of a material with a script and would like to make a second material get the same color as the first material on command. How would I go about doing this? Example 1 Shows how I currently Change Color1. Example 2 is my attempt at trying to make Color2 the same as Color1 on command.

public Material Color1;
public Material Color2;

public void Example()

public void Example2 ()
     Color2 = Color1;

After you’ve set the color, can’t you just assign it to material 2 like this:

public Material myMat;
public Material secondMat;

void Example2()
     secondMat.color = myMat.color;