CodeDom generic type constraint

后端 未结 2 956
不思量自难忘°
不思量自难忘° 2021-02-20 00:06

Is there a way to generate a class constraint with CodeDom.

Because when I use something like

var method = new CodeMemberMethod();
var genericParam = new         


        
2条回答
  •  北恋
    北恋 (楼主)
    2021-02-20 00:14

    It seems that there is no straigntforward way to specify that constraint. Neither for the "struct" constraint.

    For the "T : new()" constraint use the flag HasConstructorConstraint

    For the rest use CodeTypeReference as in this msdn example.

提交回复
热议问题