C# cannot explicity convert type

I have two list arrays and want to filter the results from one Array to another but I get a syntax error "cannot explicity convert type '...filtervaluesofattribure' to 'Systems.Collections.Generic.List...' .  How do I do this?  Is it possible to just filter the results back to the same LIST Array?

GetAllConvertedValue = FilteredProducts.Where(i => i.value1 == li.Text).FirstOrDefault();

List<FilteredValuesOfAttribure> GetAllConvertedValue = new List<FilteredValuesOfAttribure>();
List<FilteredValuesOfAttribure> FilteredValueOfProduct = new List<FilteredValuesOfAttribure>();
tmajor99Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Franck GaspozSoftware Architect, Technical ExpertCommented:
Hi,
In you example, after
GetAllConvertedValue = FilteredProducts.Where(i => i.value1 == li.Text).FirstOrDefault();

Open in new window

, GetAllConvertedValue  is not a list but null or an instance of element of type of FilteredProducts elements.
change this to :
GetAllConvertedValue = FilteredProducts.Where(i => i.value1 == li.Text).ToList()

Open in new window

to have a list as result (none or several elements)

thus, what to you mean exactly by "Ifilter the results from one Array to another" ?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
it_saigeDeveloperCommented:
Is it possible to just filter the results back to the same LIST Array?
Yes it is possible, however, you lose all of the contents of the master (or original) list.  Consider the following -
using System;
using System.Collections.Generic;
using System.Linq;

namespace EE_Q28690720
{
	class Program
	{
		static List<Person> people = new List<Person>() 
		{ 
			new Person() { ID = 1, Name = "Jim", Gender = Gender.Male }, 
			new Person() { ID = 2, Name = "Julie", Gender = Gender.Female }, 
			new Person() { ID = 3, Name = "Peter", Gender = Gender.Male }, 
			new Person() { ID = 4, Name = "Patricia", Gender = Gender.Female }, 
			new Person() { ID = 5, Name = "Vance", Gender = Gender.Male }, 
			new Person() { ID = 6, Name = "Vanessa", Gender = Gender.Female } 
		}; 

		static void Main(string[] args)
		{
			Console.WriteLine("Full list");
			foreach (var person in people)
				Console.WriteLine("{0} [{1}] is a {2}", person.Name, person.ID, person.Gender);

			people = (from person in people where person.Gender.Equals(Gender.Female) select person).ToList();

			Console.WriteLine();
			Console.WriteLine("Now filtered");
			foreach (var person in people)
				Console.WriteLine("{0} [{1}] is a {2}", person.Name, person.ID, person.Gender);

			Console.ReadLine();
		}
	}

	class Person
	{
		public int ID { get; set; }
		public string Name { get; set; }
		public Gender Gender { get; set; }
	}

	enum Gender : int
	{
		None = 0,
		Male = 1,
		Female = 2,
		Unknown = 3,
		Undeclared = 4
	}
}

Open in new window

Which produces the following output -Capture.JPG
-saige-
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.