Class CanBeNullAttribute
Indicates that the value of the marked element could be null
sometimes,
so the check for null
is necessary before its usage
Implements
Inherited Members
Namespace: JetBrains.Annotations
Assembly: UnityEngine.dll
Syntax
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Delegate, AllowMultiple = false, Inherited = true)]
public sealed class CanBeNullAttribute : Attribute, _Attribute
Examples
[CanBeNull] public object Test() { return null; }
public void UseTest() {
var p = Test();
var s = p.ToString(); // Warning: Possible 'System.NullReferenceException'
}