Adding materials to a Line Renderer through code?

Adding materials to a Line Renderer through code?

I have a material that I am using to add a glowing effect to my line renderer. I can add this as a 2nd material to the line to give it a glowing effect. 
I want to be able to add/remove this material through code, so I can essentially enable/disable the effect. I have no clue how to access the current materials of the line renderer in a way that allows me to add/remove elements from the materials array. How can I do that?
private void SetGlow()
    line.materials.Length = 2;
    line.materials[1] = "/new/material/directory/material.mat";


Answer 1:

You can have 2 public materials, assign the materials to them from the inspector and alternate between them.

LineRenderer line;
public Material mat1, mat2;

// Use this for initialization
void Start()
    line = GetComponent<LineRenderer>();

private void ToggleGlow()
    if (line.material == mat1) 
        line.material = mat2;
        line.material = mat1;

Refer to Line Renderer for more info.