|
I have a field object and I create a list of fields:
class Field { string objectName; string objectType; string fieldName; string fieldValue; //constructor... } List<Field> fieldList = new List<Field>();
Suppose I wanted to query this list...
Started by Alex on
, 8 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
I converted it to a list since the docs.
Sorry, I mistyped:
var q = from Field f a List of distinct object names from the list as defined.
To query the list fieldList, not just the class field.
|
|
I have a generic List (of Foo) which contains n objects of Type Foo. One of the properties of Foo is PropertyA. PropertyA can be one of ValueA, ValueB or ValueC. Is there an easy way of splitting this into three seperate Lists, one for ValueA, one for...
Started by Simon on
, 7 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
Something along the lines of
Dim dic as New Dictionary(Of TypeOfYourValues, List(Of Foo)) For Each e As Foo In myList If Not dic.ContainsKey(e.PropertyA) Then dic(e.PropertyA) = New List(Of Foo = from foo in list group foo....
Though.
|
|
If I have this:
a='abcdefghij' b='de'
Then this finds b in a:
b in a => True
Is there a way of doing an similar thing with lists? Like this:
a=list('abcdefghij') b=list('de') b in a => False
The 'False' result is understandable - because its rightly...
Started by monojohnny on
, 9 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
So, if you aren't concerned about the order the subset appears, you can do:
a=list('abcdefghij') b=list('de') set(b).issubset(set(a)) True
Edit after you clarify: If you need to preserve order, and the list is indeed characters as....
|
Ask your Facebook Friends
|
I have a List sort question. I am using c# 3.0 and a generic List structure like this:
public class myObject { public int ID { get; set; } public List<mySetting> setting { get; set; } } public class mySetting { public int ID { get; set; } public...
Started by Ash Machine on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
OrderBy is slightly easier than Sort :
var sorted = lmo.OrderBy(x => x.Value);
but even Sort isn't too bad:
lmo.Sort((x, y) =>... .
Well, List<T> already has a Sort method if you want to sort it in place - or you could use LINQ's OrderBy method .
|
|
Say I have a class that looks something like this:
class SomeClass { int m_member; public int Member { get { return m_member; } set { m_member = value; } } }
And somewhere else, I have a list of type List<SomeClass> list .
If I want to search the...
Started by Matthew on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Int index = list.FindIndex(m => m.Member == someMember);
If you can use Linq
SomeClass aClasss = list.FirstOrDefault(item => item.Member == someMember); .
|
|
In C++ using std::list, this is a simple matter of erasing what an iterator is pointing to (the erase statement returns the next valid member of the list).
What's the best way to iterator through a list and remove members that match a certain criteria...
Started by hamlin11 on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
In another list and next delete them in loop
But here is the cookie: http://www.koders.com is to iterate through the list in reverse order, removing items as you go:
for(int i = myList.Count-1 IEnumerable<T> , it gets more difficult....
|
|
I'm partial to using member initialization lists with my constructors... but I've long since forgotten the reasons behind this...
Do you use member initialization lists in your constructors? If so, why? If not, why not?
Started by ceretullis on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
Furthermore, if a class doesn't have a default constructor, or you have a const member variable, you must use an....
In the initializer list:
B() : a(3) { }
This would only call A 's A(int) constructor and not its default that unnecessarily.
|
|
I'm creating a specialised proxy class that implements IList<T> and wraps an internal List<T> instance.
List<T> itself implements IList<T> , which declares a member bool IsReadOnly , but when I try to access that member from my...
Started by Nathan Ridley on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
} }
This member is still accessible....
It's still available publicly { ...
Http://msdn.microsoft.com/en-us/library/aa288461(VS.71).aspx
Note that this does not make the interface member private .
It implements the interface member explicitly.
|
|
Hey there,
I'm trying to figure out what the best way to show a list of members (users) that aren't a collection (group).
/users
is my route for listing all of the users in the account
/group/:id/members
is my route for listing all of the users in the...
Started by camwest on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Support a representation consisting of a list of users and their respective groups (the resource found available_users representation for any group is likely to be only slightly smaller than the entire list.
|
|
In Visual Studio there is a drop down list in the top right hand corner that you can use to navigate to the various members in the class. Does anyone know if there is a hot key to open this ddl?
Started by Si Keep on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
From there, you can press Tab to move the cursor over to the member list to get up there, then a click on Tab will get you to the member list instead of the object list down list, and you can ....
Of a code view.
|