我想知道如何在泛型方法中赋值。我尝试更新一个对象的一些值。请看下面的代码。
电话:
this.FormaterZones(donnees); this.FormaterZones(信息);
Method :
private void FormaterZones<T>(T infos)
{
if (typeof(T) == typeof(trelEmplacement))
{
infos.emplacementDescriptionComplete = infos.emplacementDescriptionComplete.PremierMotLettreMajuscule();
}
else
{
if (typeof(T) == typeof(trelSpecification))
{
infos.specificationDescriptionComplete = infos.emplacementDescriptionComplete.PremierMotLettreMajuscule();
}
}
}
public class trelEmplacement
{
[Key]
public Guid trelEmplacementId { get; set; }
public int positionLigne { get; set; }
[StringLength(1000)]
public string? emplacementDescriptionCompleteFr { get; set; }
[StringLength(1000)]
public string? emplacementDescriptionCompleteEn { get; set; }
[StringLength(1000)]
public string? emplacementDescriptionCompleteXy { get; set; }
}
public class trelSpecification
{
[Key]
public Guid trelSpecificationsId { get; set; }
public int positionLigne { get; set; }
[StringLength(1000)]
public string? specificationDescriptionCompleteFr { get; set; }
[StringLength(1000)]
public string? specificationDescriptionCompleteEn { get; set; }
[StringLength(1000)]
public string? specificationDescriptionCompleteXy { get; set; }
}
有什么建议吗?非常感谢。