Why this Texture gives value of Null when I access it from other script

So I want to access a Texture variable that is another script from other script.

public class AssignMaterial : MonoBehaviour {

	public Texture required;

	void Start () 
	{

		required = Resources.Load("Textures/Brown") as Texture;
	}
	
}

public class DragHandler : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
	{
      AssignMaterial texture;

public void Start()
{
  texture = new AssignMaterial();
}
public void OnEndDrag (PointerEventData eventData)
{
			
	Debug.Log(texture.required.name);

}

}

The result is
NullReferenceException: Object reference not set to an instance of an object

The monobehaviour is created incorrectly, it needs to be attached to a gameObject in order for Unity to automatically call the monobehaviour methods (such as Start where the object reference is created).

One way to fix this is to properly attach the monobehaviour by replacing line 20 with

texture=gameObject.AddComponent<AssignMaterial>();

A second way to fix this is to not use a monobehaviour and instead rely on a constructor by replacing AssignMaterial’s code with

public class AssignMaterial{
     public Texture required;
 
     public AssignMaterial() 
     {
         required = Resources.Load("Textures/Brown") as Texture;
     }
}