Partager via


Erreur du compilateur CS1016

Mise à jour : novembre 2007

Message d'erreur

Argument d'attribut nommé attendu
Named attribute argument expected

Les arguments d'attribut sans nom doivent figurer avant les arguments nommés.

Exemple

L'exemple suivant génère l'erreur 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 ()
    {
    }
}