Click or drag to resize

CSharpExtensionsReplaceTrivia Method (SyntaxToken, SyntaxTrivia, SyntaxTrivia)

Creates a new token with the specified old trivia replaced with a new trivia. The old trivia may appear in the token's leading or trailing trivia.

Namespace:  Microsoft.CodeAnalysis.CSharp
Assembly:  Microsoft.CodeAnalysis.CSharp (in Microsoft.CodeAnalysis.CSharp.dll) Version: 2.3.0-dev-56735-00. Commit Hash: <developer build>
public static SyntaxToken ReplaceTrivia(
	this SyntaxToken token,
	SyntaxTrivia oldTrivia,
	SyntaxTrivia newTrivia


Type: Microsoft.CodeAnalysisSyntaxToken
Type: Microsoft.CodeAnalysisSyntaxTrivia
The trivia to be replaced.
Type: Microsoft.CodeAnalysisSyntaxTrivia
The new trivia to use in the new tree in place of the old trivia.

Return Value

Type: SyntaxToken

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type SyntaxToken. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
See Also