如何初始化数组datarow

如何初始化数组datarow

本文介绍了如何初始化数组datarow的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨所有

i想要初始化数据行阵列但我不能

任何帮助都会有用

提前感谢

我的代码

hi to all
i want to intialize data row array but i cant
any help will be usefull
thanks in advance
my code

	DataRow[] operationsOnAbcenceDataRow;
			if (rowType == (int)RowType.Absence)
			{
				if (!hasNearStartPermission && !hasNearEndPermission)
					operationsOnAbcenceDataRow = operationOnAbsenceItems.Select(" ID <>  " + (int)OperationOnAbsenceType.ExtendNearStartPermission + "  and ID <> " + (int)OperationOnAbsenceType.ExtendNearStartPermission);
				else if (!hasNearStartPermission && hasNearEndPermission)
					operationsOnAbcenceDataRow = operationOnAbsenceItems.Select(" ID <>  " + (int)OperationOnAbsenceType.ExtendNearStartPermission);
				else if (hasNearStartPermission && !hasNearEndPermission)
					operationsOnAbcenceDataRow = operationOnAbsenceItems.Select(" ID <>  " + (int)OperationOnAbsenceType.ExtendNearEndPermission);

			}

if (operationsOnAbcenceDataRow.Length != 0)
{
operationOnAbsenceItems.Clear();
foreach (DataRow row in operationsOnAbcenceDataRow)
 operationOnAbsenceItems.ImportRow(row);
}



我的问题是这行,因为operationsOnAbcenceDataRow不要initioalize我不能使用

operationsOnAbcenceDataRow.Length


my problem is this lines ,because operationsOnAbcenceDataRow dont initioalize i cant use
operationsOnAbcenceDataRow.Length

if (operationsOnAbcenceDataRow.Length != 0)
{
operationOnAbsenceItems.Clear();
foreach (DataRow row in operationsOnAbcenceDataRow)
 operationOnAbsenceItems.ImportRow(row);
}

推荐答案

if (operationsOnAbcenceDataRow != null && operationsOnAbcenceDataRow.Length != 0)
{
  operationOnAbsenceItems.Clear();
  foreach (DataRow row in operationsOnAbcenceDataRow)
    operationOnAbsenceItems.ImportRow(row);
}


这篇关于如何初始化数组datarow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 20:40