Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6246997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:47:21+00:00 2026-05-24T12:47:21+00:00

I have the following piece of code: public List<myTask> MyTask { get; set; }

  • 0

I have the following piece of code:

 public List<myTask> MyTask { get; set; }


 public class myTask
{
    public List<int> ID { get; set; }
    public List<DateTime> Date { get; set; }
    public Decimal Total { get; set; }
 }
 List<myTask> tempTask = new List<myTask>();
 MyTask = new List<myTask>();

I want to do something as follows but having the error message:

MyTask = tempTask.GroupBy(x => x.Date);

Error 1 Cannot implicitly convert type
‘System.Collections.Generic.IEnumerable,MvcUI.Models.MyTask>>’
to ‘System.Collections.Generic.List’. An explicit
conversion exists (are you missing a cast?)


Edited Code:

I have tried to add the code:

var newtempTask = tempTask.GroupBy(x => x.Date, (Date, values) =>


 new
                    {
                        ID = values.Select(x => x.ID).ToList(),
                        Date = values.Select(x => x.Date).ToList(), Total=values.Select(x => x.Date).ToList() 
                                                                          }); and then 
        foreach (var newitem in newtempTask)
        {
            MyTask.Add(new MyTask
                           {
                               ID = newitem.ID,
                               Date= newitem.Date,Total = newitem.Total
                           });}

I have tried to add the code, please see the above edited code. I am having the error message, Error 7 Cannot implicitly convert type ‘System.Collections.Generic.List>’ to ‘System.Collections.Generic.List’

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T12:47:22+00:00Added an answer on May 24, 2026 at 12:47 pm

    You lack explanations on what you are trying to achieve…
    I think the following could be what you are asking for:
    (it selects the first task in each group by date)

     List<myTask> tempTask = new List<myTask>();
     // fill tempTask
     List<myTask> Task = (from t in tempTask
                          group t by t.Date into g
                          select g.First()).ToList();
    

    Or do you perhaps want new tasks for each date with the IDs of all tasks in that group and the sum of the totals?

    In that case the query is a little more complex:

       List<myTask> Task2 = (from t in tempTask 
                             group t by t.Date into g
                             select
                               new myTask
                                 {
                                  ID = new List<int>(g.SelectMany(t => t.ID)),
                                  Date = g.Key,
                                  Total = g.Sum(t => t.Total)
                                 }).ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following piece of code: class Test{ private: int id; public: Test(int v):id(v)
I have the following piece of code: class Foo { public Foo() { Bar
I have the following piece of code in my DataModel.cs class: public User ValidateUser(string
Let's say we have the following piece of code: public class Event { }
I have the following piece of code: class ICookable { public: virtual void CookMe
I have the following piece of code: class Student { public: Student(){} void display()
I have the following piece of code: public void AddHash( int val ) {
I have the following piece of code: public class DumpLocationLog extends Thread { LocationManager
I have the following piece of code in Visual C++ 2005 : : class
I have the following piece of code in C++. int arr[] = {1, 2,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.