简体   繁体   中英

How i can add parameters to method using roslyn?

Need add input parameters to method.
I create new instance with type MethodDeclarationSyntax:

MethodDeclarationSyntax lMethodDeclarationSyntax = Syntax.MethodDeclaration(
                Syntax.List<AttributeListSyntax>(), 
                Syntax.TokenList(Syntax.Token(SyntaxKind.PublicKeyword)), 
                Syntax.IdentifierName("MemoryStream"), 
                null, 
                Syntax.Identifier("Serialize"), 
                null, 
                Syntax.ParameterList(), 
                Syntax.List<TypeParameterConstraintClauseSyntax>(), 
                Syntax.Block(lList));  

How i can add input parameter like a

(MyType lMyType)?

代替在上面的示例中使用System.ParameterList() ,而是实际上构造一个带有参数的参数列表。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM