일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- Eclipse
- Maven
- decompiler
- javascript
- Apache Lucene
- 이클립스
- 웹 서비스
- Redirect
- asp.net
- 웹뷰
- varags
- html
- Bootstrap
- SpringSource Tool Suite
- 자바
- scrollView
- jsp
- Java
- Web Service
- TextBox
- WebView
- MANTIS
- MSsql
- 안드로이드
- 자바스크립트
- 컬럼명
- Android
- STS
- C#
- MS-SQL
- Today
- Total
bboks.net™
C# Variable Arguments (Varargs) 본문
Cause
A public or protected type contains a public or protected method that uses the VarArgs calling convention.
Rule Description
The VarArgs calling convention is used with certain method definitions that take a variable number of parameters. A method using the VarArgs calling convention is not Common Language Specification (CLS) compliant and might not be accessible across programming languages.
In C#, the VarArgs calling convention is used when a method's parameter list ends with the __arglist keyword. Visual Basic does not support the VarArgs calling convention, and Visual C++ allows its use only in unmanaged code that uses the ellipse ... notation.
How to Fix Violations
To fix a violation of this rule in C#, use the params (C# Reference) keyword instead of __arglist.
When to Exclude Warnings
Do not exclude a warning from this rule.
Example
The following example shows two methods, one that violates the rule and one that satisfies the rule.
using System; namespace UsageLibrary { public class UseParams { // This method violates the rule. [CLSCompliant(false)] public void VariableArguments(__arglist) { ArgIterator argumentIterator = new ArgIterator(__arglist); for(int i = 0; i < argumentIterator.GetRemainingCount(); i++) { Console.WriteLine( __refvalue(argumentIterator.GetNextArg(), string)); } } // This method satisfies the rule. public void VariableArguments(params string[] wordList) { for(int i = 0; i < wordList.Length; i++) { Console.WriteLine(wordList[i]); } } } }
[출처] Use params for variable arguments