Convert text file to dictionary or anonymous type object
Posted
by Robert Harvey
on Stack Overflow
See other posts from Stack Overflow
or by Robert Harvey
Published on 2010-05-04T04:39:06Z
Indexed on
2010/05/04
4:48 UTC
Read the original article
Hit count: 336
I have a text file that looks like this:
adapter 1: LPe11002
Factory IEEE: 10000000 C97A83FC
Non-Volatile WWPN: 10000000 C93D6A8A , WWNN: 20000000 C93D6A8A
adapter 2: LPe11002
Factory IEEE: 10000000 C97A83FD
Non-Volatile WWPN: 10000000 C93D6A8B , WWNN: 20000000 C93D6A8B
Is there a way to get this information into an anonymous type or dictionary object?
The final anonymous type might look something like this, if it were composed in C# by hand:
new
{
adapter1 = new
{
FactoryIEEE = "10000000 C97A83FC",
Non-VolatileWWPN = "10000000 C93D6A8A",
WWNN = "20000000 C93D6A8A"
}
adapter2 = new
{
FactoryIEEE = "10000000 C97A83FD",
Non-VolatileWWPN = "10000000 C93D6A8B",
WWNN = "20000000 C93D6A8B"
}
}
© Stack Overflow or respective owner