Caching script reference via GetComponent has local scope?

I'm trying to cache a reference to another gameobject script in Start function. It works fine within the start function, but try to access the variable elsewhere and its become null.

using UnityEngine;
using System.Collections;

public class test_cacheComponent : MonoBehaviour {

    public  GameObject          go_AppManager;
    private applicationManager  m_AppManagerScript;

    void Start ()
    {
        applicationManager m_AppManagerScript = (applicationManager) go_AppManager.GetComponent(typeof(applicationManager));
        print("Test>>Start: Load m_AppManager script " + m_AppManagerScript);
        m_AppManagerScript.TestApplicationManger();
    }

    void Update ()
    {       
        print("Test>>Start: Load m_AppManager script " + m_AppManagerScript);
        m_AppManagerScript.TestApplicationManger();
    }
}

When run this will correctly print and call 'TestApplicationManger' (function simply prints OK) in Start, but come Update and m_AppManagerScript appears to be void. How come? I thought that Start() was called after all objects had been initialised and clearly AppManger is as I can call its functions, but it appears that the reference is only valid in locally in scope to the start function?

In addition I tried to check the variable with this line in Update

    if (m_AppManagerScript == null)
    {
        print("NULL");
        applicationManager m_AppManagerScript = (applicationManager) go_AppManager.GetComponent(typeof(applicationManager));
    }

But that brings up the same error 3 times in the same script error CS0135: `m_AppManagerScript' conflicts with a declaration in a child block Which i don't understand since i'm not re-declaring the variable at all.

Cheers

Your C# foo is a bit rusty:

You are declaring a field of type applicationManager, called m_AppManagerScript.

then in your Start() function, you think you are assigning a value to that field, but what you're doing is creating a local variable with the same name, and assign a value to that.

use this start function instead:

void Start ()
    {
       m_AppManagerScript = go_AppManager.GetComponent<applicationManager>();
        print("Test>>Start: Load m_AppManager script " + m_AppManagerScript);
        m_AppManagerScript.TestApplicationManger();
    }

Note that I changed the first line (and also made you use the generic GetComponent<>() instead.

Most c# programmers stick to a convention where typenames start with a capital letter by the way. Feel free to care or not care about that :)