Get the name of the collided object

Thanks in advance for reading

I’m using linecast to detect collision. The point is i need to know the name of the object I’m colliding with. So i have four empty game object around my player with linecasts from the player to these points and I can’t seem to access the name of the collided object.
Here’s the code

using UnityEngine;
using System.Collections;

public class collisiondetection : MonoBehaviour {

public RaycastHit2D collidedTop;
public RaycastHit2D collidedBot;
public RaycastHit2D collidedRight;
public RaycastHit2D collidedLeft;
public Transform collisionCheckRight;
public Transform collisionCheckLeft;
public Transform collisionCheckTop;
public Transform collisionCheckBot;

public Transform textboxprefab;
bool textbox;
public MovementScript movementscript;
// Use this for initialization
void Start () {
	movementscript = GameObject.FindGameObjectWithTag("Player").GetComponent<MovementScript>();

// Update is called once per frame
void Update () 

	collidedTop = Physics2D.Linecast(transform.position, collisionCheckTop.position, 1 << LayerMask.NameToLayer("Obstacles"));
	collidedBot = Physics2D.Linecast(transform.position, collisionCheckBot.position, 1 << LayerMask.NameToLayer("Obstacles"));
	collidedRight = Physics2D.Linecast(transform.position, collisionCheckRight.position, 1 << LayerMask.NameToLayer("Obstacles"));
	collidedLeft = Physics2D.Linecast(transform.position, collisionCheckLeft.position, 1 << LayerMask.NameToLayer("Obstacles"));



Any idea how i can get the object name?

Try this:

if (collidedTop != null && collidedTop.collider != null) {
    Debug.Log("The top name is: ";

I did a ridiculous mistake. I miss spelled the layermask name Obstacles when it’s actually Obstacle.