Error CS0029 Help? (Screenshot of Exact Error)

using UnityEngine;
using System.Collections;

public class ChangeMaterial : MonoBehaviour 
{
	private Renderer rend;

	private Shader differentShader;
	
	public int[,] materials = new int [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30];

	void Start () 
	{
		differentShader = Shader.Find ("Toon/Lit Outline");

		rend = GetComponent<Renderer> ();

		rend.enabled = true;

		rend.sharedMaterial = materials[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30];

		for (int i = 0; i < materials.Length; i++) 
		{
			rend.sharedMaterial.shader = differentShader;
		}
	}
}

81062-screen-shot-2016-10-27-at-41507-pm.png

I created this “for” loop earlier to change the Shader of all 30 elements (which are materials) at the beginning of the scene. I am using an array as opposed to a list because the indexes will not change.
The error is in line 10. What am I doing wrong?

You are declaring a two-dimensional array, yet assigning it an apparent 31-dimensional array. The materials array in a renderer is a one-dimensional array, and as such does not need any commas. Not to mention, you are assigning an integer value to a material variable. You are also not actually doing anything in the for loop, just simply repeating the exact same line 31 times. The following is how you would go about doing this;

 using UnityEngine;
 using System.Collections;
 
 public class ChangeMaterial : MonoBehaviour 
 {
     private Renderer rend;
 
     private Shader differentShader;
 
     void Start () 
     {
         differentShader = Shader.Find ("Toon/Lit Outline");
 
         rend = GetComponent<Renderer> ();
 
         rend.enabled = true;
 
         for (int i = 0; i < rend.sharedMaterials.Length; i++) 
         {
             rend.sharedMaterials*.shader = differentShader;*

}
}
}