This is just a feasibility question. I know that if I say
int myInt = "5";
I get a compile time error. What I want to do is create compile time errors or warnings on objects. So let's say I have a custom object with a few properties. One of the properties cannot be null otherwise the solution will not compile:
public static class NoNullObjects
{
//NotNullable
public static NotNullObject {get; set;}
}
MyClass.cs:
Line#55 NoNullObjects.NotNullObject = null;
When I build I want to see:
Error: NotNullObject cannot be set to null. MyClass.cs Line 55.
Is there a way to do this?