Is there a generic constructor with parameter constraint in C#? -


You can put an obstacle on a common method like:

  public Class A {public static zero method & lt; T & gt; (TA) where T: new () {// ... some ...}}  

Where do you specify that a constructor of T There should be no criteria for this. I am thinking that there is a constructor with " a float [,] parameter such as" There is a way to add a restriction "

The following code is not compiled:

  public class A {public static zero method  (tA) where T: new (float) [,] U) {// ... some ...}}   

As you've found, you do not have to

As a normal functioning, a representative who can create types of objects T :

  public class A {Public static zero method   (TA, Funk & Ltfinum; float [,], T & gt; creator) {// ... some ...} > 

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -