0
J'essaie de déclarer ref object
comme paramètre optionnel. J'ai donc compris pourquoi je ne peux pas faire ça. Le decesion était de surcharger ma méthode et maintenant j'ai un nouveau problème:Est-il possible de ne pas copier ref vers variable locale?
public Guid GetIdByEmployeeTypeName(string typeName)
{
return SurroundWithTryCatch(() => new EmployeeType().GetEmployerGroupIdByTypeName(typeName));
}
public Guid GetIdByEmployeeTypeName(string typeName, ref EmployeeType employeeType)
{
EmployeeType type = employeeType; //The problem here. I can not use ref object inside an anonymous method.
return SurroundWithTryCatch(() => type.GetEmployerGroupIdByTypeName(typeName));
}
Comment puis-je optimiser mon code?
Puis-je poser une question semi-connexe, pourquoi avez-vous besoin de passer 'EmployeeType' par ref, est-ce une struct? – CodingGorilla
Vous n'attribuez rien à 'employeeType'. Pourquoi avez-vous même besoin du modificateur 'ref' ici? –
@SriramSakthivel Ne pas copier l'objet. Comme je sais ref en C# la même chose avec & en C++ .. – user3818229