Reputation: 314
I have a problem with function using ref parameter. This function call herself using linq like this :
public Champ(tabloidConfigColonne tcc,ref Dictionary<string, Jointure> jointures)
{
...
sousChamps = lc.ToDictionary(
o => o.nom,
o => new Champ(o, ref jointures));
}
An error appear saying ref not available in anonymous function.
Full function is here
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));
}
}
thanks for your help.
Upvotes: 0
Views: 340
Reputation: 495
I don't have enough rep to comment, so...
No need to use ref
for reference types (objects) unless you will make a new instance of that object inside the function.
See this SO post for more explanation on ref
:
C# ref is it like a pointer in C/C++ or a reference in C++?
Upvotes: 1