Click here to Skip to main content
15,891,763 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
my project is class Constants_Unit
I created one metod in class ,
in this metod recive one parameter with type IEnumerable<t> and return type IEnumerable<t> how to calling this metod with Type Constants_Unit and assign return value IEnumerable<t> to object type Constants_Unit.
thanks you.
Posted
Updated 21-Oct-12 2:48am
v2
Comments
siavoshi.davod 21-Oct-12 9:12am    
public IEnumerable<t> Toring<t>(IEnumerable<t?> source) where T : struct
{
return source.Select(x => (T)x);
}

private void button1_Click(object sender, RoutedEventArgs e)
{
DataClasses1DataContext db=new DataClasses1DataContext();
IEnumerable<constants_unit> bb = (from i in db.Constants_Units
select i).ToList();
IEnumerable<constants_unit> cc = Toring<constants_unit>(bb);
}
Sergey Alexandrovich Kryukov 25-Oct-12 14:54pm    
What could be a problem? Don't know how to add a parameter to a method? What is IEnumerable (is so, why using it).
This is usual basic staff.
--SA

1 solution

It's hard to work out exactly what you want, but try:
C#
IEnumerable<Constants_Unit> myCollection = myMethod<Constants_Unit>();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900