Hi,
I need to read a file like this:
# Messages français pour GNU gettext.
# Copyright © 2006 Yoyodyne, Inc.
# Michel Robitaille <robitail@IRO.UMontreal.CA>, 2006.
# Christophe Combelles <ccomb@free.fr>, 2006
#
msgid ""
msgstr ""
"Project-Id-Version: GNU hello-pascal 0.15-pre5\n"
"Report-Msgid-Bugs-To: bug-gnu-gettext@gnu.org\n"
"PO-Revision-Date: 2006-10-01 02:29+0200\n"
"Last-Translator: Christophe Combelles <ccomb@free.fr>\n"
"Language-Team: French <traduc@traduc.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: hello.hello_world
msgid "Hello, world!"
msgstr "Bonjour, le monde !"
#: hello.running_as
#, object-pascal-format
msgid "This program is running as process number %d."
msgstr "Ce programme est exécuté en tant que processus numéro %d."
and get a sortedlist with all msgid as keyz and msgstr as values.
"Hello, world!" = "Bonjour, le monde !"
"This program is running as process number %d." = "Ce programme est
exécuté en tant que processus numéro %d."
What's the best solution to do this please ?
Read all strings "one by one" ?
Jean-Luc !
Jon Skeet [C# MVP] - 25 Mar 2008 12:34 GMT
<snip>
> What's the best solution to do this please ?
>
> Read all strings "one by one" ?
Yes, I'd read a line at a time and process lines I'm interested in.
I'd personally create a class to encapsulate the key and the value,
but you could also reuse the generic KeyValuePair struct.
When you say you want a *sorted* list, what do you want it sorted by?
If it's just "where the entries came" then you just need a List which
you add to at the end each time.
Jon
J-L - 25 Mar 2008 14:13 GMT
> Yes, I'd read a line at a time and process lines I'm interested in.
> I'd personally create a class to encapsulate the key and the value,
[quoted text clipped - 3 lines]
> If it's just "where the entries came" then you just need a List which
> you add to at the end each time.
But how to use a List<> to get key / value elements ?
After, I need to get value efficiently with (for example)
MyList["mykey"]
Jon Skeet [C# MVP] - 25 Mar 2008 14:14 GMT
> > When you say you want a *sorted* list, what do you want it sorted by?
> > If it's just "where the entries came" then you just need a List which
[quoted text clipped - 3 lines]
> After, I need to get value efficiently with (for example)
> MyList["mykey"]
Ah - you didn't say that. In that case use a List for the "in order"
version and a Dictionary for key lookups.
Jon
J-L - 25 Mar 2008 16:19 GMT
> Ah - you didn't say that. In that case use a List for the "in order"
> version and a Dictionary for key lookups.
Finally, I use a Dictionnary. Thanks for your help