I have an object that is generated in one class
public class CreatingClass
{
public T CreateObject<T>(Dictionary<string, object> parameters) where T : IMyInterface, new()
{
....
}
public void DestroyObject(IMyInterface objectToDestroy)
{
....
}
}
I call this function from a client class, then at times need to nullify it through my application by the creating class.
Can I do something like the following
public class ClientClass
{
MyObject obj;
CreatingClass creatingClass = new CreatingClass();
private void AFunctionToCreateMyClass()
{
obj = creatingClass.CreateObject<MyClass>(parameters);
}
private void AFunctionToDeleteMyObject()
{
CreatingClass.DestroyObject(obj);
Assert.IsNull(obj);//Doesn't fail
}
}
I had tried objectToDestroy = null, but didn't think it would work (and it didn't)