kalldrexx
15 years agoContributor
How do I return an empty (but not null) var with the C# api?
I am trying to return an object if it exists, and if it doesn't exist I want to return an empty var object. By an empty object, I want the following code to work:
The problem I am encountering is that in my GetAliasObject() method, if there is no mappedName I want to return an empty object, but the only way I could think to do this is with either "return new var();" or "return new var(null);". Unfortunately, both instances will cause a crash when I attempt to check the "Exists" properly with a NullReferenceException.
Is there a way to create an empty TC object that will return false (and not exception) when checking for the exists property?
var window = Utils.GetAliaseObject(myVCLObject);
if (!window["Exists"]) { .... code here ....}
The problem I am encountering is that in my GetAliasObject() method, if there is no mappedName I want to return an empty object, but the only way I could think to do this is with either "return new var();" or "return new var(null);". Unfortunately, both instances will cause a crash when I attempt to check the "Exists" properly with a NullReferenceException.
Is there a way to create an empty TC object that will return false (and not exception) when checking for the exists property?