Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Sunday, July 19, 2015 8:23 PM
This is passed from javascript.
var requestedID= rID.join(",");
List<int> myIntList= Convert.ToInt32(Request["requestedID"]);
Cannot implicitly convert type 'int' to 'System.Collections.Generic.List<int>'
All replies (2)
Sunday, July 19, 2015 9:30 PM âś…Answered
Cannot implicitly convert type 'int' to 'System.Collections.Generic.List<int>'
You can't tell System.Collections.Generic.List, a collection as a whole, that it is going to be an int. You have to be in a loop loading the collection.
If you had loaded a System.Collections.Generic.ListList<int>, then you can load another System.Collections.Generic.ListList<int> in the manner you are doing.
System.Collections.Generic.List<int> = System.Collections.Generic.List<int>
Sunday, July 19, 2015 8:46 PM
You don't convert it..
namespace ConsoleCS
{
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static void Main(string[] args)
{
int i = 1;
List<int> myIntList1 = new List<int>();
myIntList1.Add(i);
foreach (int value in myIntList1)
{
Console.WriteLine(value);
}
List<int> myIntList2 = Enumerable.Range(1,1).Select(x => i).ToList();
foreach (int value in myIntList2)
{
Console.WriteLine(value);
}
Console.WriteLine("Done.");
Console.ReadLine();
}
}
}