none
how to implicitly convert type 'int' to 'string' RRS feed

  • Question

  •  var publishers = query.ToList();
                foreach (var publisherData in publishers)
                {
                    publisherList.Add(new PublisherModel()
                    {
                        Id = publisherData.Id,
                        Name = publisherData.Name,
                        Year = publisherData.Year // Error at this point
                       
                    });
                }
                return View(publisherList);
    Thursday, January 4, 2018 1:55 PM

All replies

  • I have manage to fix the issue

     var publishers = query.ToList();
                foreach (var publisherData in publishers)
                {
                    publisherList.Add(new PublisherModel()
                    {
                        Id = publisherData.Id,
                        Name = publisherData.Name,
                        //Year = publisherData.Year
                       Year = Convert.ToInt32(publisherData.Year)
                    });
                }
                return View(publisherList);

    Thursday, January 4, 2018 2:20 PM
  • Hello Nanajoeb,

    I'm glad that you have solved the issues by yourself, it would be nice if you could close the thread by marking your reply as answer. This can be beneficial to other community members reading this thread.

    Sincerely,

    Neil Hu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, January 5, 2018 7:11 AM
    Moderator