THỨ TƯ,NGÀY 22 THÁNG 4, 2020

The original invocation off F simply tickets the fresh number arr because a value parameter

Bởi Nguyễn Hoàng Phong

Cập nhật: 03/06/2022, 02:34

The original invocation off F simply tickets the fresh number arr because a value parameter

Regarding the 2nd and you may 3rd invocations, the conventional sorts of F isn’t applicable as the zero implicit conversion process exists throughout the disagreement form of into the parameter sorts of (particular object cannot be implicitly converted to form of target[] )

A parameter eter variety. If the an official factor listing is sold with a factor number, it might be the past factor on the record therefore are of one-dimensional assortment kind of.

Example: The brands string[] and string[][] can be utilized as the sorts of a factor number, nevertheless type of string[,] can not. avoid example

https://datingranking.net/pl/mamba-recenzja/

  • New disagreement provided having a factor variety is going to be one expression which is implicitly modifiable (§ten.2) toward factor number variety of. In this situation, the brand new factor assortment acts precisely eg a value parameter.
  • As an alternative, the newest invocation normally identify no or more arguments to your parameter assortment, in which per argument is a term which is implicitly modifiable (§ten.2) into function particular the new factor range. In this situation, the brand new invocation creates an example of the fresh new parameter assortment kind of with a length equal to the amount of objections, initializes the weather of the variety instance towards the considering argument viewpoints, and you can spends the new freshly written variety for example since the actual argument.

Apart from making it possible for an adjustable quantity of objections when you look at the an invocation, a factor variety is strictly equal to an admiration parameter (§14.six.2.2) of the same variety of.

The second invocation off F immediately creates a several-feature int[] into offered feature thinking and you can passes you to variety for example given that a regard factor. As well, the next invocation away from F brings a zero-feature int[] and you can entry you to definitely like since the an admiration parameter. Another and you may 3rd invocations is actually truthfully comparable to composing:

For this reason, excess resolution picks the standard sort of F , therefore the dispute was passed due to the fact an everyday worthy of factor

When doing overload solution, a strategy having a factor assortment would be appropriate, either in its normal mode or even in the longer setting (§eleven.six.4.2). The new expanded particular a strategy is present as long as the latest typical brand of the procedure is not applicable and only when the an applicable method with the same signature as the lengthened function is not currently age method of.

On analogy, a couple of you are able to prolonged kinds of the process which have a great factor selection are actually as part of the class while the normal procedures. Such expanded variations are therefore maybe not believed when performing overburden solution, plus the very first and you may 3rd method invocations thus discover normal actions. When a category eter variety, that isn’t uncommon in order to include a number of the offered versions once the typical strategies. In that way, you’ll be able to prevent the allotment of a wide range instance that takes place whenever a broadened version of a method that have an effective factor variety is actually invoked. end example

The second invocation produces False as it is equivalent to F(new string[] < null>) and passes an array containing a single null reference. end example

If the form of a factor array are object[] , a possible ambiguity appears amongst the typical types of the procedure while the stretched form to own a single target factor. The cause of the fresh ambiguity is that an object[] are by itself implicitly modifiable to type target . The ambiguity merchandise nothing wrong, however, as they can be solved by inserting a cast if needed.

In the first and you can history invocations off F , the standard version of F applies as a keen implicit sales can be obtained on the argument type of into the parameter type (both are out-of form of object[] ). However, the newest stretched sorts of F can be applied, making it chose of the overload resolution. Thus, a-one-function object[] is established because of the invocation, therefore the unmarried element of new number are initialized on the provided disagreement worth (and that is a regard to an item[] ). prevent example

Bình luận

Tôn trọng lẫn nhau, hãy giữ cuộc tranh luận một cách văn minh và không đi vượt quá chủ đề chính. Thoải mái được chỉ trích ý kiến nhưng không được chỉ trích cá nhân. Chúng tôi sẽ xóa bình luận nếu nó vi phạm Nguyên tắc cộng đồng của chúng tôi

Chưa có bình luận. Sao bạn không là người đầu tiên bình luận nhỉ?

SEARCH