0

ref パラメータを使用する関数に問題があります。この関数は、次のように linq を使用して自分自身を呼び出します。

public Champ(tabloidConfigColonne tcc,ref Dictionary<string, Jointure> jointures)
            {
              ...
             sousChamps = lc.ToDictionary(
                            o => o.nom,
                            o => new Champ(o, ref jointures));
             }

無名関数で ref を使用できないというエラーが表示されます。

フル機能はこちら

public Champ(tabloidConfigColonne tcc,ref Dictionary<string, Jointure> jointures)
        {
            nom = tcc.champ;
            description = tcc.titre;
            type = tcc.type;
            valeurDefaut = tcc.valeurParDefaut;
            modeEdition=new Template(tcc.editeur, tcc.editeurParam1, tcc.editeurParam2, tcc.editeurParam3);
            if (!string.IsNullOrEmpty(tcc.jointure))
            {
                jointure = jointures[tcc.jointure];
                nomTable = jointure.nomNouvelleTable;
            }

            visu=tcc.visu;
            Groupe=tcc.groupe;
            Id=tcc.nom;

            valideurs = tcc.valideurs;
            Obligatoire = tcc.obligatoire;

            if (tcc.colonnes.Count>0)
            {
                List<tabloidConfigColonne> lc = tcc.colonnes.GetColonnes(visibiliteTools.getFullVisibilite(),false);
                sousChamps = lc.ToDictionary(
                    o => o.nom,
                    o => new Champ(o, ref jointures));
            }
        }

ご協力いただきありがとうございます。

4

1 に答える 1

1

コメントするのに十分な担当者がいないので...

ref関数内でそのオブジェクトの新しいインスタンスを作成しない限り、参照型 (オブジェクト)に使用する必要はありません。

詳細については、この SO の投稿を参照してくださいref: C# ref is it like a pointer in C/C++ or a reference in C++?

于 2013-06-11T17:52:09.240 に答える