너무 일반적인 것으로 표시된 다른 질문 (https://stackoverflow.com/questions/26812721/hdf5-c-sharp-examples-to-solve-3-specific-questions-i-demonstrate-what-has-been)을 작성하여보다 명확하고 간결하며 가능한 구체적으로 다시 작성하고 있습니다. 필자는 Visual C++ 및 HDF5 (www.hdfgroup.org 참조)를 사용하여 일부 데이터 집합을 출력했습니다. 모든 것이 잘 작동합니다. 나는C# HDF5 출력 (특성)이 Visual C++와 동일해야합니다. 또는 C#에서의 C#에서의 HDF5 형식과 그 차이점은 무엇입니까?
Name Value Type Array Size
Board Name UltraMaster String,length=256 Scalar
Card number 0 32-bit integer Scalar
를 얻을 난을 수출하는 C의 #을 사용하는 경우, 내가 예를 들어 HDF5 자바 뷰어를 사용하여
DataSpace attr_dataspace = DataSpace(H5S_SCALAR);
Attribute attribute_cardNum = dataSet.createAttribute(
attrCardNumber, PredType::STD_I32BE, attr_dataspace, PropList::DEFAULT);
attribute_cardNum.write(PredType::NATIVE_INT, &cardNumber); // write out the card number
및
StrType strdatatype(PredType::C_S1, 256); // of length 256 characters
// Create attribute and write to it
Attribute attribute_boardName = dataSet.createAttribute(
attrBoardName, strdatatype, attr_dataspace);
attribute_boardName.write(strdatatype, asciiBoardName);
를 사용하는 C++의 속성이 서식을 지정하려면 HDF5 (hdf5.net에서 라이브러리 사용) :
Name Value Type Array Size
Board Name ˜„ String, length=256 1
Card Number 0 32-bit integer 1
배열 크기가 이제 스칼라 대신 "1"이며 보드 이름의 값이 완전히 위로 올려집니다. C# 코드가 다릅니다 (분명히 :). 나는 가지고있다 :
// Create card Number attribute
H5AttributeId attrCardId = H5A.create(dataSetId, "Card Number", typeId,
H5S.create_simple(1, new long[1] { 1 }));
H5A.write(attrCardId, new H5DataTypeId(H5T.H5Type.NATIVE_INT),
new H5Array<int> (new int[]{cardNumber}));
// Create Board Name attribute
byte[] asciiStr = ASCIIEncoding.ASCII.GetBytes("Board Name");
H5AttributeId attrBoardNameId = H5A.create(dataSetId, "Board Name",
H5T.create(H5T.CreateClass.STRING, 256), H5S.create_simple(1, new long[1] { 1 }));
H5A.write(attrBoardNameId, H5T.create(H5T.CreateClass.STRING,256),
new H5Array<string>(new string[] { GetBoardNameFromCardNum(cardNumber) }));
내가 말했듯이 결과는 다르다. C# 모방은 C++ 출력을 모방하는 것이 바람직합니다 (C++ 코드를 변경할 수 있다고 생각합니다). 그래서 특히,
- 어떻게 배열 크기는
- 방법 I 출력 보드 이름 "스칼라"으로받을 수 있나요? 이게 내가 C# 문자열 (유니 코드)을 다루고 있고 C++ ASCII 문자열이 아니라는 사실과 관련이 있다고 가정합니다. 사람이 어떤 나중에에서이 필요합니다 경우