I have an object result of type IEnumerable and an object res of type Object. I want to concatenate both, how can i do
IEnumerable<V_Student_Attendace_DayWise> result;
V_Student_Attendace_DayWise res;
result.Concat(res); // Error here...
I have an object result of type IEnumerable and an object res of type Object. I want to concatenate both, how can i do
IEnumerable<V_Student_Attendace_DayWise> result;
V_Student_Attendace_DayWise res;
result.Concat(res); // Error here...
The Enumerable.Concat
method expect a collection as its argument, so you have to give the input as a collection in order to get it concatinated. So the code for this will looks like the following, where res
the object that you already having
result = result.Concat(new[] { res});
You can try this as well:
result = result.Concat(new[] { new V_Student_Attendace_DayWise()});
The answers given are good, but please be aware that you're not tacking new items onto the end of your IEnumerable
. You are creating a new collection that consists of the old collection with the new item tacked on at the end. (If the collection that implements IEnumerable
happens to implement IList
as well, you could cast and Add
for improved performance and memory usage, but different semantics.)