I have the following piece of code which checks if a particular DataRow has a column of a particular name and if it is not NULL.
private static bool HasValue(DataColumn c, DataRow row)
{
if (c != null && row != null && row[c.ColumnName] != System.DBNull.Value)
{
return true;
}
return false;
}
Also I am processing the columns of a datarow and parsing it into corresponding datatypes.
foreach (DataColumn c in row.Table.Columns)
{
switch (c.ColumnName)
{
case Constants.Literals.ACTIVATIONDATETIME:
if (HasValue(c, row))
{
bFound = true; credentialInfo.ActivationDateTime = DateTimeOffset.Parse(Convert.ToString(row[c.ColumnName]));
}
break;
}
}
Visual Studio shows this as cyclomatically complex. Is there any way to reduce the cyclomatic index on this function.