2
votes
1answer
111 views

Optimization expression evaluation chalange

It's my first message on this site. I'm trying to evaluate/learn C#. I'm an old (C++, MFC) programmer. I'm trying to learn C# with this little program(game) for my children. I'm trying to calculate ...
4
votes
5answers
214 views

Want to remove the goto in my code

I want to remove my goto's in this code but I'm not sure how. There must be a cleaner way to write my code. Perhaps move the "if" statement to the end of each loop then use break? Sorry if this is a ...
4
votes
3answers
235 views

How to improve this method? (Create text without repetition)

The basic idea is not to allow the same texts and add +1 at the end. Imagine that I have a datagrid (wpf) with names, and every time I click the add button, I will put a new name on the list ...
3
votes
2answers
117 views

Is this a right and effcient way of checking AND in a for loop

Just saw this at work in a code review and was wondering if this style of coding - for loop, doing && like that, seems fine to you or is there a better way of doing the same? for (int j = 1; ...
2
votes
1answer
317 views

filter a collection in a PagedCollectionView

I have scenario wherein I have to filter a collection in a PagedCollectionView. The filter criteria are Name and status which are check boxes with Enabled and Disabled labels If Enabled is checked it ...
3
votes
1answer
148 views

return false if one of members fails a condition

I want to validate a list of objects for example strings. and if one of the objects fails to pass the condition return false as validation result . this is the code I use : public static bool ...
4
votes
2answers
501 views

Optimisations for this loop? (Garbage collection is slowing it down)

I'm working on a Game Of Life clone as my first project. I'm still relatively new to programming, so my code is probably not really optimised. The biggest bottleneck is in my Start() method, but that ...
2
votes
1answer
103 views

Improve grouping in LINQ

I have a collection (Child Collection) on which I am performing some operation to make another collection (Parent Collection). But that I do in a dirty foreach loop. I want to do it in an elegant way. ...
3
votes
4answers
453 views

How to remove some for loops c#

I am looking for a way to lose some of the loops in the code below. Looking at it, something isn't right. I cant figure out how to reduce the code, whilst retaining the same outcome. public ...
-1
votes
1answer
228 views

Infinite loop craziness [closed]

This had me puzzled and I know it shouldn't have for (UInt16 i = 0; i < UInt16.MaxValue; i = (UInt16)(i + 64)) { // do something // oops - infinite loop } resulting in an infinite loop ...
3
votes
3answers
394 views

Improve my Task Loops

How can I improve up this code? Is it ok to write code using Invoke and Action so liberally or is this bad? Performance is not an issue as I'm not using Invoke 50,000x in a a row (a lot of other ...
3
votes
6answers
688 views

How can I improve the performance of this loop

#region GetBookListByPriority private static List<BCBook> GetBookListByPriority(List<BCBook> listBcBook) { List<BCBook> newList = new List<BCBook>(); try { ...
9
votes
2answers
410 views

Is this a valid loop?

I have the following code: private ScatterViewItem FindScatterViewOfSourceFile(SourceFile find) { foreach (ScatterViewItem svi in classScatterViews) { if ((svi.Tag as ...
9
votes
5answers
1k views

Horribly nested while loops

So, I am stuck with this horrible object model coming back from a 3rd party product. It's six levels of objects deep, and I have to loop through the collection in each level, to get the values I ...
10
votes
4answers
404 views

Is there a better way to interrupt lengthy for loops?

I have this piece of code I would like some help with. I'm running a lengthy process that I want to interrupt at any time. The thing is, as you can see in the code, I have if(stop) everywhere, also in ...

1 2
15 30 50 per page