using "IS" is better or checking for "NOT NULL"

Posted by BDotA on Programmers See other posts from Programmers or by BDotA
Published on 2012-10-30T19:50:56Z Indexed on 2012/10/30 23:19 UTC
Read the original article Hit count: 180

In C#.NET language: This style of coding is recommended or the one below it?

        if (sheet.Models.Data is GroupDataModel)
        {
            GroupDataModel gdm = (GroupDataModel)sheet.Models.Data;
            Group group = gdm.GetGroup(sheet.ActiveCell.Row.Index);   
            if (group!=null && controller != null)
            {
                controller.CheckApplicationState();
            }
        }

or this one:

        var gdm = sheet.Models.Data as GroupDataModel;
        if (gdm != null)
        {
            Group group = gdm.GetGroup(sheet.ActiveCell.Row.Index);   
            if (@group!=null && controller != null)
            {
                controller.CheckApplicationState();
            }
        }

© Programmers or respective owner

Related posts about coding-style

Related posts about coding-standards