Howdy,
I need to set the height of every textbox on my form, some of which are nested within other controls. I thought I could do something like this:
private static IEnumerator<TextBox> FindTextBoxes(Control rootControl){ foreach (Control control in rootControl.Controls) { if (control.Controls.Count > 0) { ...
This is in C#, I have a class that I am using from some else's DLL. It does not implement IEnumerable but has 2 methods that pass back a IEnumerator. Is there a way I can use a foreach loop on these. The class I am using is sealed.
...
I posted an answer to this question, including a very short rant at the end about how String.Split() should accept IEnumerable<string> rather than string[].
That got me thinking. What if the base Object class from which everything else inherits provided a default implementation for IEnumerable such that everything now returns an Enume...
Is it safe to assume that two itterations over the same collection will return the objects in the same order? Obviously, it is assumed that the collection has not otherwise been changed.
...
private IEnumerable<string> Tables
{
get {
yield return "Foo";
yield return "Bar";
}
}
Let's say I want iterate on those and write something like processing #n of #m. Is there a way I can find out the value of m without iterating before my main iteration?
I hope I made myself clear.
...
I'd like to do the equivalent of the following in LINQ, but I can't figure out how:
IEnumerable<Item> items = GetItems();
items.ForEach(i => i.DoStuff());
What is the real syntax?
...
In a LINQ to SQL class, why are the properties that are created from the foreign keys EntitySet objects, which implement IEnumerable, where as the objects on the DataContext are Table objects which implement IQueryable?
EDIT: To clarify, here is an example that illustrates what I'm trying to understand. This example:
ctx.Matches.Where(...
Hi everyone,
I am currently coding a simple Data Access Layer, and I was wondering which type I should expose to the other layers.
I am going to internally implement the Data as a List<>, but I remember reading something about not exposing the List type to the consumers if not needed.
public List<User> GetAllUsers() // non C# users: t...
What is the best way to localize a collection (IEnumerable)?
From the BL I retrieve a collection of entities which still need to localized, I figured I write a method which extends the IEnumerable and returns the localized list.
How can i get the code underneath working? Any ideas? Maybe better options?
public static IEnumerable L...
This might be a old question: Why does IEnumerable<T> inherit from IEnumerable?
This is how .NET do, but it brings a little trouble. Every time I write a class implements IEumerable<T>, I have to write two GetEnumerator() functions, one for IEnumerable<T> and the other for IEnumerable.
And, IList<T> doesn't inherit from IList.
I don'...
Hi, I have 3 classes
public class Item
{
...
}
public class Order
{
public List Items
...
}
public class Customer
{
public List Orders
...
}
Now, using LINQ I need to get all items that a customer bought. How can I?
I tried something like var items = from o in cust.Orders select o.Items; but result is IEnuberable> and I wanna just one...
I just want to verify, is yield return a shortcut for implementing IEnumerable and IEnumerator?
Thanks,
John
...
If have a set of classes that all implement an interface.
interface IMyinterface<T>
{
int foo(T Bar);
}
I want to shove them all in a list and enumerate through them.
List<IMyinterface> list
foreach(IMyinterface in list)
// etc...
but the compiler wants to know what T is. Can I do this? How can I overcome this issue?
...
Hi, I know a lot about C# but this one is stumping me and Google isn't helping.
I have an IEnumerable range of objects. I want to set a property on the first one. I do so, but when I enumerate over the range of objects after the modification, I don't see my change.
Here's a good example of the problem:
public static void Generic...
i have a few classes that i am trying to move to using generics
Class1: Curve
this class has the following code:
public class Curve : IEnumerable
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator(); // Calls non-interface method
}
public RTRatePointEnumerator GetEnumerator()
{
return new ...
I am trying to filter an IEnumerable object of the duplicate values, so I would like to get the distinct values from it, for example, lets say that it holds days:
monday
tuesday
wednesday
wednesday
I would like to filter it and return:
monday
tuesday
wednesday
What is the most efficient way to do this in .net 2.0?
...
Why is list1Instance and p lists in the Main method of the below code pointing to the same collection?
class Person
{
public string FirstName = string.Empty;
public string LastName = string.Empty;
public Person(string firstName, string lastName) {
this.FirstName = firstName;
this.Las...
I'm using C# on Framework 3.5. I'm looking to quickly group a Generic List<> by two properties. For the sake of this example lets say I have a List of an Order type with properties of CustomerId, ProductId, and ProductCount. How would I get the sum of ProductCounts grouped by CustomerId and ProductId using a lambda expression?
...
I have a class that parses very large file (that can't fit in memory) and I'm currently utilizing the IEnumerable interface to use foreach so I can easily grab the parsed contents of the file line by line. Currently, I'm trying to write this to file using an XMLSerializer. It insists on enumerating the class and in my case, this means ...
When I have entities in my domain with lists of things, should they be exposed as ILists or IEnumerables? E.g. Order has a bunch of OrderLines.
...