19.5 Array covariance

原创 2006年05月25日 05:46:00
For any two reference-types A and B, if an implicit reference conversion (§1
3.1.4) or explicit reference
conversion (§13.2.3) exists from A to B, then the same reference conversion
also exists from the array type
A[R] to the array type B[R], where R is any given rank-specifier (but the
same for both array types). This
relationship is known as array covariance. Array covariance, in particular,
means that a value of an array
type A[R] may actually be a reference to an instance of an array type B[R],
provided an implicit reference
conversion exists from B to A.
Because of array covariance, assignments to elements of reference type
arrays include a run-time check
which ensures that the value being assigned to the array element is
actually of a permitted type (§14.13.1).
[Example: For example:
class Test
static void Fill(object[] array, int index, int count, object value) {
for (int i = index; i < index + count; i++) array[i] = value;
static void Main() {
string[] strings = new string[100];
Fill(strings, 0, 100, "Undefined");
Fill(strings, 0, 10, null);
Fill(strings, 90, 10, 0);
Chapter 19 Arrays
The assignment to array[i] in the Fill method implicitly includes a
run-time check, which ensures that
the object referenced by value is either null or an instance of a type that
is compatible with the actual
element type of array. In Main, the first two invocations of Fill succeed,
but the third invocation causes a
System.ArrayTypeMismatchException to be thrown upon executing the first
assignment to
array[i]. The exception occurs because a boxed int cannot be stored in a
string array. end example]
Array covariance specifically does not extend to arrays of value-types. For
example, no conversion exists
that permits an int[] to be treated as an object[].


PhotoLine 20 and 19.5 Keygen

  • 2016年11月30日 01:02
  • 64KB
  • 下载

Regularized Gaussian Covariance Estimation

我之前写过一篇介绍 Gaussian Mixture Model (GMM) 的文章,并在文章里贴了一段 GMM 实现的 Matlab 示例代码,然后就不断地有人来问我关于那段代码的问题,问得最多的就...

Covariance and Contra-variance

Previous to .NET 4, generic interfaces were invariant. .NET 4 adds an important extension for generi...
  • iammew
  • iammew
  • 2012年03月31日 13:38
  • 143

covariance matrix and capital allocation

  • 2012年01月26日 23:21
  • 1.17MB
  • 下载

期望 方差 协方差 协方差矩阵 (Expectation Variance Covariance)

在学习机器学习的算法时经常会碰到随机变量的数字特征,所以在这里做一个简单的总结。 1、         期望(Expectation) 离散: 其中,f(x)为随机变量x的概率函...

Covariance Matrix 协方差矩阵

Covariance Matrix All of the covariances c(i,j) can be collected together into a covariance m...
您举报文章:19.5 Array covariance