In ASP.Net there is no variant type. We have object type equivalent to variant. While assigning the object (variant in ASP) to something (another object), we should keep in mind that this object will be assigned byRef while in ASP the same (variant) was getting assigned byVal. The ASP equivalent of assigning variant in ASP.NET is to assign clone of the object (shallow copy) instead of object itself (deep copy). for eg: Incorrect: Dim variantA as Object Dim variantB as Object for i = 0 to 3
variantA = arrValue( i )
variantB( i ) = variantA
next Correct: Dim variantA as Object Dim variantB as Object for i = 0 to 3
variantA = arrValue( i )
variantB( i ) = variantA.Clone()
next In Incorrect e.g., the values at earlier indices of variantB will be overwritten with last value of variantA in every iteration. Eventually values at all the indices of variant B will be equal to arrvalue(3) (last value).
No comments:
Post a Comment