c# - Parameter type using Generics constraint VS Explicit type declaration -


These two seem to be different in similar announcements?
When will you choose one syntax on another?

There are no performance penalties for either of the cases to be selected on top of each other

  Public zero imports and lt are any special reason ;; T & gt; ( < The text after the "pre" 

The difference is that before you will be allowed pass some pass such that the IFileInfo < More to implement / code> Uses the OS type. For example:

  function & lt; IEnumerable & lt; SpecialFileInfo & gt; Lister = () => ListFiles (); Import (lister, file = & console.wrightline (file.SpecialProperty));  

(Where SpecialProperty is a property which is present on SpecialFileInfo but not IFileInfo .) Could not do that together later on

There is a very slight execution time for normal methods and types -. It will be jitted once for each different value type T type logic (do not forget to apply a value type IFileInfo ) and once for all the reference type (ie Once it was jitted or a reference type, it will not need to be jitted again.) It will almost certainly be negligible in your actual application.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -