編譯器錯誤 CS1016
更新:2007 年 11 月
錯誤訊息
必須是具名屬性引數
Unnamed 屬性 (Attribute) 的引數必須出現在具名引數之前。
範例
下列範例會產生 CS1016:
// CS1016.cs
using System;
[AttributeUsage(AttributeTargets.Class)]
public class HelpAttribute : Attribute
{
public HelpAttribute(string url) // url is a positional parameter
{
m_url = url;
}
public string Topic = null; // Topic is a named parameter
private string m_url = null;
}
[HelpAttribute(Topic="Samples", "http://intranet/inhouse")] // CS1016
// try the following line instead
//[HelpAttribute("http://intranet/inhouse", Topic="Samples")]
public class MainClass
{
public static void Main ()
{
}
}