TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mohan S
NA
34
39.2k
Cannot implicitly convert type 'int' to 'System.Collections.
Nov 5 2015 2:33 PM
Hi Guys,
Program is to:
Find elements less than the input given in the list??
i/p : {1,2,3,4}
i/p : 4
o/p : {1,2,3}
ERROR: Cannot implicitly convert type 'int' to 'System.Collections.Generic.List<int>
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please enter list of cities");
List<int> input1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Please enter second city name");
int input2 = Convert.ToInt32(Console.ReadLine());
int output =
UserProgramCode.GetElements(input1, input2);
Console.WriteLine(output);
Console.ReadLine();
}
}
class UserProgramCode
{
public static List<int> GetElements(List<int> input1, int input2)
{
List<int> output = new List<int>();
foreach (int li in input1)
{
if (li < input2)
{
output.Add(li);
}
}
if (output.Count >= 1)
{
output.Sort();
output.Reverse();
return output;
}
else
{
output.Add(-1);
return output;
}
}
}
}
Reply
Answers (
7
)
Form Location
How can I pass data to DataGridView from another form?