How can I Optimize below code with ternary conditional operator ?:
I am new to Linq Need to know some optimization with operator ?:
Thank you
- private string GetFunctionId(FunctionType functionType)
- {
-
- string _Id;
- int _Count;
- if (functionType == FunctionType.abc)
- {
- _Count = Collection.Where(f => f.Function == functionType).Count();
- _Id = String.Format("{0}{1}", "A", Count + 1);
- return _Id;
- }
- else
- {
- Count = Collection.Where(f => f.Function != TimeProgramFunctionType.FunctionType).Count();
- _Id = String.Format("{0}{1}", "B", Count + 1);
- return _Id;
- }
- }
Output should Be
if true A1,A2,A3
else B1,B2,B3