|
foreach is just a for loop, the compiler inserts the for loop in place of your code. I don't see how any of them are going to have any significant differences.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I just wanted to know which of those are faster so that I can implement in my coding.
Regards,
Blumen
|
|
|
|
|
Like I said, I doubt any of them are. foreach and a for loop are the *same* thing. Choose based on what suits your needs at the time, speed is never going to be an issue between them
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: foreach is just a for loop, the compiler inserts the for loop in place of your code
You are wrong here. foreach only works on IEnumerable and is using an IEnumerator internally.
Robert
|
|
|
|
|
Really ? OK. I knew it was just syntactic sugar, but apparently I got the details wrong. Thanks for the heads up.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
For You :
For Loop is the best option
Develop2Program & Program2Develop
|
|
|
|
|
How on earth could you possibly say that without knowing anything about the situation it's going to be used in or what the requirements are?
|
|
|
|
|
the assumption that the OP is a clueless noob because he posted without answering any of your questions.
--
You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer
|
|
|
|
|
|
The best iterator is the one that gives the most readable code in the context it is used in.
|
|
|
|
|
Nice answer.
|
|
|
|
|
There is no best iterator.
That's why there is more than one, it all depends on the circumstances
(or your definition of best: performance, readability, susceptibility to
mistakes, ...).
|
|
|
|
|
They are all about the same when using smaller data sets. The only time you will notice differences in speed between the iterators is when you use large data sets. By large data sets I mean in the 100,000 plus data records range. But there are other factors involved here as well such as the operations being done between the iterations.
For best optimization look at the operations being done between the iterations and I'm guessing you will gain more speed over changing your iterator.
Phil
|
|
|
|
|
|
How can I detect whether a certain field retrieved from the database contains an image or other type of blob?
I have a MSAccess table with an OLE-Object field holding a bitmap. This field is added to the DataTable as an System.Byte[] type. How do I know whether this field actually holds an bitmap?
Thanks for any help you can give.
Regards,
Kees Vermeulen
|
|
|
|
|
The only way you can get this info is by inspecting the data in the field. You can either extract it and try to load it into an image or you can read the header bytes to see if they conform to known types.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
|
I am using .NET 3.9 in VS 2005. If I double-click on control to create a click event, nothing happens. There is also no event tab in the properties window.
Does anyone have an idea on what could cause this / what the cure is ?
Johan Lombaard
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former - Albert Einstein
|
|
|
|
|
Oops, .NET 3.0
Johan Lombaard
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former - Albert Einstein
|
|
|
|
|
You need to define the event with the associated event handler in XAML markup. VS 2005 (with WPF) wont automatically create an default event handler when you double click a control.
|
|
|
|
|
I have .NET 3.0 installed. I've not noticed any side-effects.
Kevin
|
|
|
|
|
I have an class library which uses Micrisoft Office Excel Object library for creating Excel objects. I want to include these dll's as a part of my class library dll. I tried using ILMerge utility, but could not merge these assemblies. Since Micrisoft.Office.Interop.Excel is a COM object I tried converting it into .Net assembly by using tlbImp. But am not able to do it. Please help in including it with my dll.
|
|
|
|
|
You can't. The client has to have Office installed in order to use this.
tlbImp doesn't convert anything to a .NET assembly. It creates a Runtime Callable Wrapper assembly that has to be used ALONG WITH the COM component. It will NOT replace the COM component.
|
|
|
|
|
Thanks a lot for the reply. I can understand that the client needs to have Excel installed on its machine. But I wish to use my library as a component so that the client may just add a reference to my dll and then call the required functions. For this to happen in current scenario the client will have to have the excel object library too in the bin folder.
|
|
|
|
|
jain.ashish21 wrote: For this to happen in current scenario the client will have to have the excel object library too in the bin folder.
Is that such a big deal?
|
|
|
|