Elad
Member
- Joined
- Feb 15, 2020
- Messages
- 20
- Programming Experience
- 1-3
Hello! I wanted to know how to send to a function that accepts a particular interface as null or at least as an empty variable? Here is the code:
public Package(Priority priority, Address senderAddress, Address destinationAdress)
{
PackageID = count++;
Priority = priority;
Tracking = new List<Tracking>();
SenderAddress = senderAddress;
DestinationAddress = destinationAdress;
//The null is painted green,
AddTracking(null);
}
public void AddTracking(INode node, Status status = Status.CREATION)
{
Tracking.Add(new Tracking(MainOffice.Clock, node, status));
}
//And Interface
public interface INode
{
void CollectPackage(Package pack);
void DeliverPackage(Package pack);
string GetName();
void Work();
}
I get such a warning "Cannot convert null literal to non-nullable reference type."
By the way in java interface can be set to null why in c # it does not work in this logic?