Article ID: 897545 - Last Review: May 18, 2007 - Revision: 1.3 Your Visual C# .NET application may be vulnerable to array covariance issues
For a Microsoft Visual Basic .NET version of this article, see 896579
(http://support.microsoft.com/kb/896579/
)
.
SUMMARYThis article describes array covariance issues to which a Microsoft Visual C# .NET 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 C# .NET 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 C# .NET language specification, visit the following Microsoft Developer Network (MSDN) Web site: http://msdn2.microsoft.com/en-us/library/aa664572(VS.71).aspx
(http://msdn2.microsoft.com/en-us/library/aa664572(VS.71).aspx)
| Article Translations
|
Back to the top
