Replacing sharedMaterials by an existing Material C#

My question is why this is working and changing the color:

gameObject.GetComponent<Renderer> ().sharedMaterials[1].color =;

But replaced by this it isn´t changing the material:

gameObject.GetComponent<Renderer> ().sharedMaterials[1] = Resources.Load ("NewMaterial/TestMat") as Material;

or this;

Material NewMat = new Material (Resources.Load ("NewMaterial/TestMat") as Material);
Debug.Log (NewMat); // working!!
gameObject.GetComponent<Renderer> ().sharedMaterials[1] = NewMat;

I don´t get an error and the material “TestMat” is stored in the right folder!
As an Unity-Beginner i probably overlooked something obvious!
Thanks for helping!!!

for better understanding

using UnityEngine;
using System.Collections;

public class SetMaterialToo_04 : MonoBehaviour 
	void Start() {

		Material[] materials = gameObject.GetComponent<Renderer> ().sharedMaterials;
		int Arraylength = materials.Length;
		Debug.Log (Arraylength);

		for (int i = 0; i < Arraylength; i++) {
			string matName = materials *.name;*
  •  	if (matName == "Test_rot") {* 
  •  		int var = i;*
  •  		Debug.Log (materials [var]);*
  •  		Material NewMat = new Material (Resources.Load ("NewMaterial/TestMat") as Material);*
  •  		Debug.Log (NewMat); // working!!*
  •  		gameObject.GetComponent<Renderer> ().sharedMaterials [1] = NewMat;*
  •  	}*
  •  }*
  • }*

gameObject.GetComponent ().sharedMaterials and gameObject.GetComponent ().materials return a copy of the array that stores the materials.

mesh.materials = {mat1}
copyMaterials = mesh.materials
copyMaterials = {mat1}

So we do not expect that editing the copy to affect the original.

copyMaterials = {newMat}
mesh.materials = {mat1}

In addition, the copy of the array of materials stores the original materials. So editing the materials contained in the copy of the array also edits the materials contained in the original array

mesh.materials = {mat1} (where mat1 has had a new color assigned)

However you can change mesh.materials by assigning to it

Material[] materials=gameObject.GetComponent<Renderer> ().sharedMaterials;
materials[1]=Resources.Load ("NewMaterial/TestMat") as Material;
gameObject.GetComponent<Renderer> ().sharedMaterials=materials;