Testing for null interface pointer
i know should , simple but....
having following definitions
namespace xyz.dataconversions
{
public interface iimportablefiletype : iwindowsfiletypedescriptor, ifiletypedescriptor, ioptionsdialogprovider
{
void import(ilist<iimportitem> items, importexportresult result = null);
void import(ilist<string> sourcefilepaths, string destinationfolder, importexportresult result = null);
void import(string sourcefilepath, string destinationfolder, importexportresult result = null);
}
}
and this
namespace xyz.dataconversions
{
public static class abcimports
{
public static readonly iimportablefiletype dxf;
public static readonly iimportablefiletype cmx;
public static readonly iimportablefiletype hpgl;
}
}
how test null situation (the following throws exception because hpgl null)
if (abcimports.hpgl != null)
thanks in advance
i think that there problem. exeception get?
i distilled code in example , works no exception thrown:
void main() { if (abcimports.dxf != null) console.writeline ("not null"); else console.writeline ("it null"); /* outputs: "it null" */ } // define other methods , classes here public interface imyface { bool dosomething(); } public static class abcimports { public static readonly imyface dxf; public static readonly imyface cmx; public static readonly imyface hpgl; }
william wegerson (www.omegacoder.com)
Visual Studio Languages , .NET Framework > Visual C#
Comments
Post a Comment