'objType' is not defined… Actually, it is, so why is this happening?

前端 未结 2 1627
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-15 08:12

As you seen in this picture below, for some reason my DirectCast wont except ANYTHING for the second argument. It says it requires a type, but, it won\'t take any object at

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-15 08:47

    DirectCast requires an object prototype (i.e. just giving it the intended class name) rather than a System.Type descriptor object. To cast an object using a System.Type, you will want to utilize CTypeDynamic():

    Return CTypeDynamic(createElementByIdAndLayer.MemberwiseClone(), objType)
    

    The error is essentially telling you a class with the type name "objType" does not exist.

提交回复
热议问题