[英]Is there a better way to do this? (Compare/Merge specific properties on two objects)
[英]How to compare two conditons on a single line in a better way
可以做得更好嗎?
private bool IsEntityNeeded(EntityType type) => EntitiesRequiredToBuildComposite.Contains(type) && !RequirementsObtainedDict.ContainsKey(type);
RequirementsObtainedDict
是一個Dictionary<EntityType, AbstractEntity>
EntitiesRequiredToBuildComposite
是一個List<EntityType>
如果兩個條件都為真,我想返回一個布爾值,並且它必須在一行代碼中。
我知道我可以進行比較並創建一個函數來執行此操作,然后調用所述函數,但這將創建更多的代碼行,這不是我想要的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.