Article ID: 896579 - Last Review: December 3, 2007 - Revision: 2.6 Your Visual Basic .NET or Visual Basic 2005 application may be vulnerable to array covariance issues
For a Microsoft Visual C# .NET version of this article, see 897545
(http://support.microsoft.com/kb/897545/
)
.
SUMMARYThis article describes array covariance issues to which a Microsoft Visual Basic .NET or Microsoft Visual Basic 2005 application is vulnerable. MORE INFORMATIONAn array covariance occurs when the following conditions are true:
Array covariance means that an element of an array that has an element type of A is actually an element of an array that has an element type of B if the following conditions are true:
Array covariance does not apply to an array of values. The following Visual Basic .NET or Visual Basic 2005 code example demonstrates how the System.ArrayTypeMismatchException exception is thrown when you run a console application. Notice that function F takes a class A object as a parameter. However, function F actually receives a class B object. This behavior causes the System.ArrayTypeMismatchException exception to be thrown at run time. REFERENCESFor more information about array covariance from the Visual Basic .NET language specification, visit the following Microsoft Developer Network (MSDN) Web site: http://msdn2.microsoft.com/en-us/library/aa711607(VS.71).aspx
(http://msdn2.microsoft.com/en-us/library/aa711607(VS.71).aspx)
APPLIES TO
| Article Translations
|
Back to the top
