Что такое "использование ???"утверждение, которое мне нужно поместить в начало моего файла класса C #, чтобы создать фрагменты кода GitHub> HDF.PInvoke> cookbook?
Например, если я вставлю приведенный ниже фрагмент кулинарной книги в класс C #, он не создается, потому что, как я полагаю, оператор «using» отсутствует и генерирует эту ошибку:
«H5A не существует в текущем контексте.»
private bool ReadStringAttribute(hid_t objectId, string title, out string value)
{
value = "";
hid_t attributeId = 0;
hid_t typeId = 0;
try
{
attributeId = H5A.open(objectId, title);
typeId = H5A.get_type(attributeId);
var sizeData = H5T.get_size(typeId);
var size = sizeData.ToInt32();
byte[] strBuffer = new byte[size];
var aTypeMem = H5T.get_native_type(typeId, H5T.direction_t.ASCEND);
GCHandle pinnedArray = GCHandle.Alloc(strBuffer, GCHandleType.Pinned);
H5A.read(attributeId, aTypeMem, pinnedArray.AddrOfPinnedObject());
pinnedArray.Free();
H5T.close(aTypeMem);
value = System.Text.ASCIIEncoding.ASCII.GetString(strBuffer);
return true;
}
catch (Exception ex)
{
return false;
}
finally
{
if (attributeId != null) H5A.close(attributeId);
if (typeId != null) H5T.close(typeId);
}
}