Click here to Skip to main content
15,879,535 members
Home / Discussions / C#
   

C#

 
GeneralRe: webrowser control Pin
Eddy Vluggen12-Sep-14 11:00
professionalEddy Vluggen12-Sep-14 11:00 
GeneralRe: webrowser control Pin
Member 1105956913-Sep-14 23:36
Member 1105956913-Sep-14 23:36 
Questionadd code to build millisecond to testing progressbar in c# 2008 Pin
KaKoten9-Sep-14 18:40
KaKoten9-Sep-14 18:40 
AnswerRe: add code to build millisecond to testing progressbar in c# 2008 Pin
PIEBALDconsult9-Sep-14 19:45
mvePIEBALDconsult9-Sep-14 19:45 
GeneralRe: add code to build millisecond to testing progressbar in c# 2008 Pin
KaKoten11-Sep-14 1:39
KaKoten11-Sep-14 1:39 
AnswerRe: add code to build millisecond to testing progressbar in c# 2008 Pin
CPallini9-Sep-14 19:59
mveCPallini9-Sep-14 19:59 
GeneralRe: add code to build millisecond to testing progressbar in c# 2008 Pin
KaKoten11-Sep-14 1:39
KaKoten11-Sep-14 1:39 
QuestionAny **FAST** way to convert IEnumerable to IEnumerable<T>? Pin
SledgeHammer019-Sep-14 18:16
SledgeHammer019-Sep-14 18:16 
I have an object[]. I need to convert it to IEnumerable T **FAST**.

Right now I have (this part is called ONCE and EnumFactory is cache):

C#
MethodInfo mi = typeof(Enumerable).GetMethod("CastIterator", BindingFlags.NonPublic | BindingFlags.Static).MakeGenericMethod(from);

ParameterExpression[] param = new ParameterExpression[] { Expression.Parameter(typeof(object[])) };

EnumFactory = Expression.Lambda<Func<object[], object>>(Expression.Call(mi, param), param).Compile();

Then I call it as (this part is called millions of times):

C#
return EnumFactory(oArray);


Most of the examples you'll see call typeof(Enumerable).GetMethod("Cast"), but if you look at that in reflector, you'll see it does a few useless checks and then calls CastIterator. To save time on the useless checks and the extra method call, I call CastIterator directly.

Any other options? EnumFactory is, of course, cached. If I comment out the part that fills in oArray, its negligible compared to calling EnumFactory. I do not know T at compile time.
GeneralRe: Any **FAST** way to convert IEnumerable to IEnumerable<T>? Pin
PIEBALDconsult9-Sep-14 19:42
mvePIEBALDconsult9-Sep-14 19:42 
GeneralRe: Any **FAST** way to convert IEnumerable to IEnumerable<T>? Pin
SledgeHammer019-Sep-14 20:07
SledgeHammer019-Sep-14 20:07 
GeneralRe: Any **FAST** way to convert IEnumerable to IEnumerable<T>? Pin
Pete O'Hanlon9-Sep-14 20:46
mvePete O'Hanlon9-Sep-14 20:46 
GeneralRe: Any **FAST** way to convert IEnumerable to IEnumerable<T>? Pin
SledgeHammer0110-Sep-14 6:46
SledgeHammer0110-Sep-14 6:46 
GeneralRe: Any **FAST** way to convert IEnumerable to IEnumerable<T>? Pin
PIEBALDconsult10-Sep-14 3:14
mvePIEBALDconsult10-Sep-14 3:14 
GeneralRe: Any **FAST** way to convert IEnumerable to IEnumerable<T>? Pin
SledgeHammer0110-Sep-14 6:42
SledgeHammer0110-Sep-14 6:42 
Questionadd row to datagridview by checking child node check box of treeview Pin
Member 110597999-Sep-14 15:39
Member 110597999-Sep-14 15:39 
AnswerRe: add row to datagridview by checking child node check box of treeview Pin
Member 1105979911-Sep-14 7:55
Member 1105979911-Sep-14 7:55 
QuestionChat Application Pin
Kevin Marois9-Sep-14 11:23
professionalKevin Marois9-Sep-14 11:23 
AnswerRe: Chat Application Pin
Ravi Bhavnani9-Sep-14 11:36
professionalRavi Bhavnani9-Sep-14 11:36 
GeneralRe: Chat Application Pin
Kevin Marois9-Sep-14 11:37
professionalKevin Marois9-Sep-14 11:37 
GeneralRe: Chat Application Pin
Ravi Bhavnani9-Sep-14 11:39
professionalRavi Bhavnani9-Sep-14 11:39 
GeneralRe: Chat Application Pin
Kevin Marois9-Sep-14 11:40
professionalKevin Marois9-Sep-14 11:40 
GeneralRe: Chat Application Pin
Kevin Marois9-Sep-14 11:46
professionalKevin Marois9-Sep-14 11:46 
GeneralRe: Chat Application Pin
Ravi Bhavnani9-Sep-14 11:57
professionalRavi Bhavnani9-Sep-14 11:57 
GeneralRe: Chat Application Pin
Kevin Marois9-Sep-14 11:58
professionalKevin Marois9-Sep-14 11:58 
GeneralRe: Chat Application Pin
Ravi Bhavnani9-Sep-14 12:00
professionalRavi Bhavnani9-Sep-14 12:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.