我有一个项目列表,其中包含对帖子的所有评论和回复。我想通过将 CommentID 与 ReplyToCommentId 进行比较,根据评论和回复来格式化它。
这是我使用 foreach 循环来获得我想用 linq 替换的结果
List<UserComment> comments = GetComments(SomeID).ToList();
int i = 0;
  foreach(var item in comments) {
    if(item.IsReply == false) {
      i++;
      formatedComments.Add(item);
      foreach(var replys in comments) {
        if(item.CommentID == replys.ReplyToCommentId) {
          i++;
          formatedComments.Add(replys);
        }
      }
    }
这在 LINQ 中是否可行。
提前致谢。