|
Hi,
How do I sort List<List<string>> according to number of fields?
The list got structure like
a|b|c|d|eeee|rere|ewew| ewqewq|ewew| ewew|ewewewewew|
By Sort I'd like to do it according to numbers of blockes (asc/desc)
EDIT
the <list<...
Started by Skuta on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Var sorted * x.Count.CompareTo(y.Count....
If you don't need to sort "in place" you can use LINQ to give you a new sorted, list.
To create a list that's sorted by the number of elements within a particular string in another list.
|
|
Ended up with this awful data structure:
List<KeyValuePair<string, KeyValuePair<string, string>>>
It's not likely to get huge (<1K I estimate) and I am gonna iterate this list over and over.
Anyone can think of some better alternative...
Started by JohnIdol on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
string,string>>>
Then, instead of storing a single KeyValuePair, you could look up the liststruct MrStruct { public string Key1, public string Key2, public string Value1 } List<MrStruct>;
This is assuming that....
|
|
What is the most suitable container just for strings holding in some array with non-predetermined upper boundary, which length is unknown on it's creation.
For simple code like:
Foo list = new Foo(); // size in unknown for()/foreach()/do()/while() // ...
Started by abatishchev on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
A StringCollection is just a type safe.
A wrapper for another type of list, the parameterless constructor initialises the Collection<T> have to cast the items to String when reading from it.
|
Ask your Facebook Friends
|
I want to store an list of key value pair lists in a lightweight structure. This seems too cumbersome. What's better? Does List<Dictionary<string, string>> add much a overhead? What other options are available?
Started by paulwhit on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
StringPair and also define a shorthand for a listDictionary< string, string> and List< KeyValuePair< string, string>> could both this:
public class MyShorthand : List....
string, string> into something shorter, e.g.
|
|
I am currently doing this:
Set<String> listOfTopicAuthors = .... List<String> list = Arrays.asList( listOfTopicAuthors.toArray( new String[0] ) );
Can you beat this ?
Started by Jacques René Mesrine on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
List<String> list = new ArrayList<String>(listOfTopicAuthors);
List<String> l.
|
|
I have a variable that can either contain a list of strings or a just a string. Is there a good way to tell what kind I'm dealing with?
"192.168.1.18" vs. ["192.168.1.18", "192.168.1.19"]
In either case I want to use the bits involved.
Started by Fylke on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
An alternative would be when generating this string/list of strings to always putI sometimes....
Or if you are not interested in actually pulling apart the string/list of strings you could do:
if is_list earlier.
|
|
What is the cleanest way to create a comma-separated list of string values from an IList<string> or IEnumerable<string> ?
String.Join(...) operates on a string[] so can be cumbersome to work with when types such as IList<string> or IEnumerable...
Started by Daniel Fortunov on
, 9 posts
by 9 people.
Answer Snippets (Read the full thread at stackoverflow):
Dim strs As New List(Of String) Dim arr As ArrayIEnumerable<string> can be converted into a string array very easily with LINQ (.NET 3.5):
IEnumerable<string> ....
ToArray and then run a string.join command on the array .
|
|
I need to often convert a "string block" (a string containing return characters, e.g. from a file or a TextBox) into List<string> .
What is a more elegant way of doing it than the ConvertBlockToLines method below?
using System; using System.Collections...
Started by Edward Tanguay on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
string[] lines = data....
You know that string now has a .Split() that takes a string[] array, right?
So ...
strings (see StringSplitOptions )
LINQ!
var linesEnum = testBlock.Split(new string = linesEnum.ToList();
Hmm.
|
|
How can I transform the following XML into a List<string> or String[] :
<Ids> <id>1</id> <id>2</id> </Ids>
Started by PintSizedCat on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
") .Select(element => element.Value) .ToList(); foreach (string value in list) { Console.WriteLine ArrayList list = new ArrayList(); XmlDocument doc = new XmlDocument(); // Loading from a XML string System.Xml.Linq; public....
|
|
I am trying to take one string, and append it to every string contained in a list, and then have a new list with the completed strings. Example:
list = ['foo', 'fob', 'faz', 'funk'] string = 'bar' *magic* list2 = ['foobar', 'fobbar', 'fazbar', 'funkbar...
Started by Kevin on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
New_list = [word_in_list + end_string for word_in_list in old_list]
Using_list = ['foo', 'fob', 'faz', 'funk'] string = 'bar' my_new_list = [x + string for....
It shadows the built-in type.
|