|
|
__John_ wrote:
It uses a 'lazy' strategy, ie. only evaluating an expression or executing a function when the result is actually needed, am I right?
Yes you are right. It's a principle of Linq to defer execution until is needed. And Linq also evaluate only the elements needed to return the result
Let's take Wayne List and do some examples
List<Person> peoples = new List<Person> {new Person("wayne"), new Person("sarah"), new Person("mark"), new Person("simon"), new Person("ashleigh"), new Person("dave"), new Person("connor"), new Person("bronwyn"), new Person("chantelle"), new Person("will"), new Person("chris")};
int Count = people.Count(p => p.Name.StartsWith("w"));
var firstperson = people.Where(p => p.Name.Length == 5).Take(3);
foreach (var p in firstperson)
{
Console.WriteLine(p.Name);
}
var firstperson2 = people.Where(p => p.Name.Length == 5).Take(3);
people.Insert(1, new Person("Vince"));
foreach (var p in firstperson)
{
Console.WriteLine(p.Name);
}
http://blogs.msdn.com/b/charlie/archive/2007/12/09/deferred-execution.aspx[^]
__John_ wrote: BTW: How can I enumerate the results more that once?
If you use a Enumerator<t>, you can use Reset to set the enumerator to its initial position, which is before the first element in the collection.
But if you use a foreach loop, you can reuse an Enumerable<t> many times. The foreach loop will start at the beginning every time.
Vince
Remember the dead, fight for the living
|
|
|
|
|
|
Nice examples - thanks!
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Nice examples.Thanks.Its more clear now.
-Manognya
__________________________________________________
$ God gives what is best.Not what all you wish
|
|
|
|
|
Hello,
I have a VBA application and we are planning to convert that to Visual Studio 2010.
In the VBA application I am using a 3 D Array. But when I increase the size of the array it goes out of memory. Following is the code:
Global stockpileArray(-1 To 135, -1 To 80, -1 To 1090) As Block
Public Type Block
trainID As String
moisture As Double
blockType As BLOCK_TYPE
segmentNum As Integer
locationID As String
End Type
I would like to know the memory limitation of ASP.NET C# Application.
Can I create 30 of the above arrays in C# app?
Thanks,
|
|
|
|
|
|
The LED lights are on but it looks like one ones at home.
"You get that on the big jobs."
|
|
|
|
|
All .NET applications have a built in memory limitation: no single object may exceed 2Gb.
This means that an array of Strings may contain 268, 435, 456 strings (assuming the references are 64 bit).
Your array contains only 12,267,528 elements, but if these are composite objects which take up more than 175 bytes each then they will not fit in a single object.
You could try declaring Block as a Class instead of a Type - that should mean that each element of your array only takes a single reference instead of the whole Block. There will be a performance penalty associated with the extra access - how bad that would be will be down to how you use it.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Which certainly explains why applications you've got running on your 64-bit computer processor, applications which have proclaimed themselves 64-bit despite actually running under a Waring-blender-meld of bittedness, shimmed up by this and that in your own special way in order to run on your toaster, don't actually pop-up any toast that isn't burnt to a crisp.
(Late to the party I suppose ... but hey! There are icons for that now: )
|
|
|
|
|
Are you into reruns of "the best of OG" or something?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
At some point you've got to cast your aspersions upon something unidentifiable and today I was just exercising an old CP trick to see whether I could auspiciously peg the post that caused the ticker on the front page to make that sound ...
Guess I'm not lucky because it wasn't this umteenth page.
|
|
|
|
|
I agree with what OG said. I want to add you should reconsider using a 3D array. In a lot of situations, a multi-dimensional array is not really needed.
Also, do all elements contain meaningful data, or is a majority of them just empty? If a lot are empty, switching from a structure to a reference type is advantageous. And if all or most full, is there a major axis? you may want to consider jagged arrays (e.g. a 1D array of 2D arrays, each with smaller sizes)?
If you need more help, explaining what it is about would be a good start.
|
|
|
|
|
Hello,
Presently I we have a VBA application.
1. We have scheduled tasks using Scheduled Tasks under System Tools.
2. The Schedule task opens a xlsm file and inside the Workbook_Open() method I call some procedures.
For Example:
Private Sub Workbook_Open()
MyMethod()
End Sub
3. The user does not need to interact with the application.
Now the company wants to convert the VBA application to .NET Application. I do not know what kind of application to choose from the following:
1. ASP.WEB Application
2. Windows Application
3. Windows Service Application
4. Console Applications.
Kindly Advice.
Thanks.
|
|
|
|
|
i think that if the user doesn't need to interact with the application, and the work can be scheduled, the better choice would be Windows Service Application, but, if you'll need to be able to start the process by hand at any time, i think console application is more straightforward to you and to the person that will use your application...
what type are your vba application? it's an excell macro?
|
|
|
|
|
What does your company, or your boss, or whoever, think they will gain by converting it ? Is there some functionality that is going to be added ... now, or in the future ... to the existing solution; or is some data or "report" going to be "sent out" or "published" in a way that is not happening now ?
If there are new requirements, I think we can better respond to your scenario if we know what they are.
best, Bill
"It is the mark of an educated mind to be able to entertain a thought without accepting it." Aristotle
modified 8-Jan-12 5:47am.
|
|
|
|
|
I agree with Bill. "If it ain't broken, don't fix it"
My choice would be to create a service and dump the scheduled task altogether. I can't remember why now but I've had problems with scheduled tasks in the past.
The service could monitor for a given event, time, file added, updated etc.
"You get that on the big jobs."
|
|
|
|
|
How often does it run? If fairly often, then a Windows Service; if not, console.
|
|
|
|
|
hi,
i am working on a USB HID KEYBOARD device. i want to register the device for the notification whenever it gets attached and removed from the system. i want to register it for all windows operating system(for all 32 and 64 bits) starting from XP.
it's a proximity device. User configures the keystrokes from the application provided with the device. As soon as user gets away from the range of the device, the device fires the keystrokes that were configured and saved by the user in the device. The device don't have any keys in it. It just fires the keystrokes configured and saved in it. The device has just the sensor in it.
can anyone provide me the solution how to do register the device?? i am using HID.dll, SETUPAPI.dll and kernel32.dll for this purpose.
|
|
|
|
|
|
using CodeDomProvider, you can compile without running the new code (yielding a CompilerResults), as well as run it without recompiling it (using CompilerResults.CompiledAssembly).
|
|
|
|
|
thank you for your answer.
I know how to create the CompilerResults and how to call a special method of the CompilerResults.
but I want to call a method as if no other method was called before it.
if I call a method of the assembly, for example foo(), which changes a static variable a, i want to call an other method, for example bar(), which is not affected of the change of the value of the static variable a.
do you know, what I mean. sorry for my bad english.
|
|
|
|
|
The statics of a class are executed once, at the first reference to said class. You can't undo that without unloading the class. The whole purpose of statics is to execute once.
And you can't unload a class, the only relevant thing you can unload is an AppDomain. So if you need a fresh class, you could load it in a separate AppDomain, use it, then unload the AppDomain. And again and again.
|
|
|
|
|
thank you very much for your help.
I'm going to try it
|
|
|
|
|
i created a list<string[]> and added data to it
List<string[]> dataArray = new List<string[]>();
dataArray.Add(new string[] { "start", "end" });
dataArray.Add(new string[] { "start2","end2" });
dataArray.Add(new string[] { "start3", "end3" });
now i want to delete the string[] containing {"start2","end2"} how to do it using built in functions like contains,find or by any other methods ?
when i tried following ....
List<String> Key = new List<String> { "start2","end2" };
dataArray.RemoveAll(k => k.Contains(Key));
getting an error :Compiler Error CS0411
The type arguments for method 'method' cannot be inferred from the usage. Try specifying the type arguments explicitly.
can any one help ????
JANARDHAN
|
|
|
|