Creating an Array of unknown type

前端 未结 3 1057
北恋
北恋 2021-01-05 15:33

I have an object which I must validate values off the problem, some of the attributes of the Objects are arrays of custom objects. Such that it will involve some boring down

3条回答
  •  旧时难觅i
    2021-01-05 16:25

    As Oli Charlesworth points out, you can not use the variable name to cast. For a generic type, you will have to cast to Object or Object[].

    Also the Object -> Object[] cast looks illegal. You probably just want a straight cast like so:

    public Object[] getAttribArray(RIORepeatingGrpEnum repeatingGrp)
    {
        Object[] grp = (Object[])getAttrib(repeatingGrp.toString());
        return grp;
    }
    

提交回复
热议问题