[求助]:如何用枚举形做数组下标
大家好,请问在VC2005下如何用枚举类型作数组下标啊?<BR><BR>部分原代码:<BR>..............<BR>public:<BR> enum class TextBoxIndices<BR> {<BR> ACCOUNT,<BR> FIRST,<BR> LAST,<BR> BALANCE<BR> };<BR><BR>................<BR>public: void SetTextBoxValues(array<String ^> ^values)<BR> {<BR> if (values->Length != TextBoxCount)<BR> {<BR> throw (gcnew ArgumentException(String::Concat(<BR> L"There must be ", (TextBoxCount + 1).ToString(), L" strings in array")));<BR> }<BR> else<BR> {<BR> this->txb_Account->Text = values[TextBoxIndices::ACCOUNT];<BR> this->txb_LastName->Text = values[TextBoxIndices::LAST];<BR> this->txb_FirstName->Text = values[TextBoxIndices::FIRST];<BR> this->txb_Balance->Text = values[TextBoxIndices::BALANCE];<BR> }<BR> }<BR>编译出错,显示下标类型没有转换。<BR>错误 1 error C2440: 'initializing' : cannot convert from 'BankLibrary::BankUIForm::TextBoxIndices' to 'int' i:\visual studio 2005\projects\banklibrary\banklibrary\BankUIForm.h 204 <BR>错误 2 error C3262: invalid array indexing: 0 dimension(s) specified for 1-dimensional 'cli::array<Type,dimension> ^' i:\visual studio 2005\projects\banklibrary\banklibrary\BankUIForm.h 204 <BR> <BR><BR>页:
[1]
