Click here to Skip to main content
15,870,165 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am working on excel comments using C#.
if (Fcount > 0)
{
comment = string.Join(Environment.NewLine, dtModified.AsEnumerable().Where(p => p.Field<string>(Constants.FuncName) == FunName1 && (string)p[Constants.Date] == date && (string)p[Constants.PF] == "F").Select(a => a.Field<string>(Constants.Time))) + "LL:" + LowLevel + "," + "Value:" + Value + "," + "HL:" + HighLevel;
}
If Fcount is 6 then
I should get the output as(comment variable )
1:06:42 AM,LL:3,Value:0.699428437325653,HL:10
1:06:42 AM,LL:3,Value:0.699428437325653,HL:10
1:06:42 AM,LL:3,Value:0.699428437325653,HL:10
1:06:42 AM,LL:3,Value:0.699428437325653,HL:10
1:06:42 AM,LL:3,Value:0.699428437325653,HL:10
1:06:42 AM,LL:3,Value:0.699428437325653,HL:10
But
I am getting the out put as

1:06:42 AM
1:08:19 AM
1:09:57 AM
1:11:35 AM
1:13:13 AM
1:14:51 AMLL:3
3
3
3
3
3,Value:0.699428437325653
0.718108917040355
0.718004332154577
0.717611501159894
0.716311910658491
0.716757724249684,HL:10
10
10
10
10
10

Please help on this

What I have tried:

I am working on excel comments using C#.

While working on populatimg the comments to excel not able to append the data line by line
Posted
Updated 14-Jun-16 5:30am

1 solution

Your parentheses are in the wrong place:
C#
comment = string.Join(Environment.NewLine, 
    dtModified.AsEnumerable()
    .Where(p => ...)
    .Select(a => a.Field(Constants.Time))
) + "LL:" + LowLevel + "," + "Value:" + Value + "," + "HL:" + HighLevel;

Move the additional information inside the Select projection:
C#
comment = string.Join(Environment.NewLine, 
    dtModified.AsEnumerable()
    .Where(p => ...)
    .Select(a => a.Field(Constants.Time) + "LL:" + LowLevel + "," + "Value:" + Value + "," + "HL:" + HighLevel)
);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900