Problem:
You need a class that contains a list of objects; each of these objects in turn contains a list of objects. You want to use a nested foreach loop to iterate through all objects in both the outer and inner arrays in the following manner:
...
Problem:
You need to add foreach support to a class, but the normal way of adding an iterator (i.e, implementing IEnumerable on a type and returning a reference to this IEnumerable from a member function) is not flexible enough. Instead of simply it...
Problem:
You want elements contained in your generic type to be enumerated using the foreach statement.
Solution:
Add an iterator to your generic type, as shown here:
public class ShoppingList<T>
{
public ShoppingList() {}
...
Problem:
You want elements contained in your non-generic type to be enumerated using the foreach statement.
Solution:
Add an iterator to your non-generic type, as shown here:
public class NGShoppingList
{
public NGShoppingList() {}...
Problem:
You need to add a new iterator that accepts parameters to a type in order for the iterator to do special processing during the looping operation.
Solution:
Add a method that is public, returns an IEnumerable, and uses the yield return...
Problem:
You need to add an iterator to a type that already implements the GetEnumerator iterator method; however, the iterators that you need to add are simple enough that they do not require parameters to be passed in to them as in Recipe 6.5. for...
Problem:
You need the ability to iterate over two or more collections and enumerate all elements in each set using a foreach loop construct. In addition to this, you also want to be able to iterate over the unique elements in each set and the duplic...
Problem:
You have a requirement that if an iterator encounters malformed or out-of-bounds data that the iterations are to stop immediately.
Solution:
It is possible to throw an exception from an iterator, which terminates the iterator and the ...
Problem:
You have added a try/finally block to your iterator and you notice that the finally block is not being executed when you think it should.
Solution:
Wrap a try block around the iteration code in the GetEnumerator iterator with a finall...
Problem:
You have a class that implements an interface with many methods. These methods support only the interface functionality and don't necessarily relate well to the other code in your class. You would like to keep the interface implementation c...
Problem:
Occasionally as a developer you run into a situation in which it would be handy to be able to regenerate your class based on a set of data that can change. You need to be able to do this without destroying all of the logic you have already ...
AJAX popular information C# language guides Windows books and cookbooks
.......
С 2009 года мы стали переводить структура сайта на различные языки. Сайт теперь будет содержать книги не только на английском языке, но также и на других европейских языках, в том числе и на Русском языке.