need help adding all gameobjects with a specific name to a list

hello again, can anybody help me add all gameobject with the name Hostile to a list. sombody else helped me make it but i cant get it working though

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class PistolRay : MonoBehaviour {

	bool canFire = true;
	public GameObject decal;
	public float clipAmmo = 8;
	public float storedAmmo = 80;
	float missingShots = 0;
	GameObject player;
	GameObject characterControler;
	bool reloading = false;
	private List<EnemyAi> enemies = new List<EnemyAi>();

	// Use this for initialization
	void Start () {

	}
	
	// Update is called once per frame
	void Update () {
		player = GameObject.Find("Player");
		CharacterControler characterControler = player.GetComponent<CharacterControler>();
		characterControler.ammoCount = clipAmmo;
		characterControler.totalAmmo = storedAmmo;
		enemies.Add(EnemyAi);
		//HERE^
		RaycastHit hit;
		Ray shooterRay = new Ray(transform.position, transform.forward);

		if(Input.GetButton("Fire1") && canFire && clipAmmo > 0){
			if(GameObject.Find ("EnemyAi") != null){
				foreach(EnemyAi enemy in enemies){
				Debug.Log("Test");
			EnemyAi enemyAi = enemy.GetComponent<EnemyAi>();
			enemyAi.couldHearGun = true;
			StartCoroutine (SoundCooldown(1));
			}
		}
		}

		if(Input.GetButton("Fire1") && canFire && clipAmmo > 0){
			Debug.DrawRay (transform.position, transform.forward, Color.green);
				if(Physics.Raycast(shooterRay, out hit, Mathf.Infinity)){
				if(hit.collider.tag == "Enemy"){
					hit.transform.GetComponent<EnemyCC>().health -= 15;
				}
			}
			var hitRotation = Quaternion.FromToRotation(Vector3.up, hit.normal);
			Instantiate(decal, hit.point, hitRotation);	
			//GameObject decalInstance = 
			//decal.transform.parent = hit.transform;
			canFire = false;
			clipAmmo -= 1;
			missingShots += 1;
			StartCoroutine(FireRate(1));
			}
		if(Input.GetButtonDown("Fire1") && canFire && clipAmmo == 0 && !reloading){
			reloading = true;
			StartCoroutine(ReloadTime(3));
		}

		if(Input.GetButtonDown("Reload") && storedAmmo != 8 && !reloading){
			reloading = true;
			StartCoroutine(ReloadTime(3));
		}
		}
	public IEnumerator FireRate (float delay){
		yield return new WaitForSeconds(delay);
		canFire = true;
	}
	public IEnumerator SoundCooldown(float delay){
		GameObject enemy = GameObject.Find("EnemyAI");
		EnemyAi enemyAi = enemy.GetComponent<EnemyAi>();
		yield return new WaitForSeconds(delay);
		enemyAi.couldHearGun = false;

	}
	public IEnumerator ReloadTime (float delay){
		yield return new WaitForSeconds(delay);
		reloading = false;
		if(storedAmmo >= 8){
			storedAmmo -= missingShots;
			clipAmmo += missingShots;
			missingShots = 0;
		}
	}
}

I’m not sure what you are looking for, but maybe you want this at line 23:

var enemyObjects =  GameObject.FindGameObjectsWithTag ("EnemyAi");
foreach(GameObject enemyObj in enemyObjects)
{
    EnemyAi enemyAi = enemyObj.GetComponent<EnemyAi>();
    if(enemyAi != null)
    {
      enemies.Add(EnemyAi);
    }
}

For the code above to work, you need to tag all your EnemyAi objects with the tag “EnemyAi”. It will look for them by tag, not by name, and this is the way to do it, finding by name should be avoided.