Events
17 Mar, 11 pm - 21 Mar, 11 pm
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
ByVal
(IDE0081)Property | Value |
---|---|
Rule ID | IDE0081 |
Title | Remove ByVal |
Category | Style |
Subcategory | Unnecessary code rules (expression-level preferences) |
Applicable languages | Visual Basic |
This rule flags an unnecessary ByVal keyword in a parameter declaration in Visual Basic. Parameters in Visual Basic are ByVal
by default, hence you do not need to explicitly specify it in method signatures. It tends to produce noisy code and often leads to the non-default ByRef keyword being overlooked.
This rule has no associated code-style options.
' Code with violations
Sub M(ByVal p1 As Integer, ByRef p2 As Integer)
End Sub
' Fixed code
Sub M(p1 As Integer, ByRef p2 As Integer)
End Sub
If you want to suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.
#pragma warning disable IDE0081
// The code that's violating the rule is on this line.
#pragma warning restore IDE0081
To disable the rule for a file, folder, or project, set its severity to none
in the configuration file.
[*.{cs,vb}]
dotnet_diagnostic.IDE0081.severity = none
To disable all of the code-style rules, set the severity for the category Style
to none
in the configuration file.
[*.{cs,vb}]
dotnet_analyzer_diagnostic.category-Style.severity = none
For more information, see How to suppress code analysis warnings.
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Events
17 Mar, 11 pm - 21 Mar, 11 pm
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register now