I have a class, I am using list to get (assigning multiple list entry values in c#).
// This will return me more than 1 records.
List<ClassEmpInfo> employeeDetails =GetEmployeeInformation();
List<ClassEmployee> empInfo = null;
foreach (ClassEmployee employee in employeeDetails)
{
//This needs to show all the ids belonging to employeeDetails.
//If there are 3 different employee ids ,
//the list empInfo should hold the output of all the 3,
//but i am getting the last 3rd one alone.
//How to cumulatively add 3 different employee ids.
empInfo = GetEmployeeDetails(Id, EmpId);
}
I am getting the last employee information rather than all the employee details in the empInfo list.
If the type is string I can do something like:
if (strType.Length > 0)
{
strType = strType + returned values;
}
else
{
strType = strType;
}
How do I add the list values cumulatively?
I think what you want to do is the following:
It’s rather unclear to me, though, if
GetEmployeeDetailsreturns a single value or a list of values. If it returns a list of values, then change the line in the loop to: