microsoft.public.dotnet.languages.csharp


TOPIC: Select XML Node
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/65c8d80b201ba538?hl=en
==============================================================================

== 1 of 4 ==
Date: Sun, May 11 2008 4:56 pm
From: "Tim Jarvis"


Thom Little wrote:

> Using C# 3.5 I want to select a value from an XML file.  The intent
> of the following is to print "EpsilonGamma".  It does not work.  Can
> you point out my probably very obvious error?
>
> XmlDocument document = new XmlDocument();
> document.Load("sample.xml");
> XmlElement root = document.DocumentElement;
> XmlNode node = root.SelectSingleNode("//menu[id=b]");
> Console.Write(
> node.SelectSingleNode("//menu[id=b]/row[id=1]/vis").Value );
> Console.Write(
> node.SelectSingleNode("//menu[id=b]/row[id=0]/vis").Value );
>
> For ...
>
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <menus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>    <menu>
>         <id>a</id>
>         <row>
>                <id>0</id>
>                <vis>Alpha</vis>
>         </row>
>         <row>
>                <id>1</id>
>                <vis>Beta</vis>
>         </row>
>    </menu>
>    <menu>
>         <id>b</id>
>         <row>
>                <id>0</id>
>                <vis>Gamma</vis>
>         </row>
>         <row>
>                <id>1</id>
>                <vis>Epsilon</vis>
>         </row>
>    </menu>
> </menus>
>
>
> ... Thom
> ___________________________________________________
>    Thom Little  -  www.tlanet.net  -  Thom Little Associates, Ltd.

Hi Thom,

Apart from the excellent replies that you already have, given that you
are using C# 3.5, maybe you should also think about using Linq for XML,
I personally find that this is the absolute best way to work with XML,
not just the query syntax, but the whole new xml API that does not work
with a DOM, sooo much easier.

In this case, one way do do this would be....

     XElement xe = XElement.Load(@"C:\Temp\Test.xml");

     var elements = from menu in xe.DescendantsAndSelf("menu")
                    where (string)menu.Element("id") == "b"
                    from row in menu.Descendants("row")
                    select row;

     StringBuilder sb = new StringBuilder();

     foreach (XElement x in elements)
     {
       sb.Append((string)x.Element("vis"));
     }
     MessageBox.Show(sb.ToString());

Regards Tim.

--





== 2 of 4 ==
Date: Sun, May 11 2008 4:58 pm
From: "Tim Jarvis"


Tim Jarvis wrote:

> Thom Little wrote:
>
> > Using C# 3.5 I want to select a value from an XML file.  The intent
> > of the following is to print "EpsilonGamma".  It does not work.  Can
> > you point out my probably very obvious error?
> >
> > XmlDocument document = new XmlDocument();
> > document.Load("sample.xml");
> > XmlElement root = document.DocumentElement;
> > XmlNode node = root.SelectSingleNode("//menu[id=b]");
> > Console.Write(
> > node.SelectSingleNode("//menu[id=b]/row[id=1]/vis").Value );
> > Console.Write(
> > node.SelectSingleNode("//menu[id=b]/row[id=0]/vis").Value );
> >
> > For ...
> >
> > <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> > <menus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> >    <menu>
> >       <id>a</id>
> >       <row>
> >              <id>0</id>
> >              <vis>Alpha</vis>
> >       </row>
> >       <row>
> >              <id>1</id>
> >              <vis>Beta</vis>
> >       </row>
> >    </menu>
> >    <menu>
> >       <id>b</id>
> >       <row>
> >              <id>0</id>
> >              <vis>Gamma</vis>
> >       </row>
> >       <row>
> >              <id>1</id>
> >              <vis>Epsilon</vis>
> >       </row>
> >    </menu>
> > </menus>
> >
> >
> > ... Thom
> > ___________________________________________________
> >    Thom Little  -  www.tlanet.net  -  Thom Little Associates, Ltd.
>
> Hi Thom,
>
> Apart from the excellent replies that you already have, given that you
> are using C# 3.5, maybe you should also think about using Linq for
> XML, I personally find that this is the absolute best way to work
> with XML, not just the query syntax, but the whole new xml API that
> does not work with a DOM, sooo much easier.
>
> In this case, one way do do this would be....
>
>       XElement xe = XElement.Load(@"C:\Temp\Test.xml");
>
>       var elements = from menu in xe.DescendantsAndSelf("menu")
>                      where (string)menu.Element("id") == "b"
>                      from row in menu.Descendants("row")
>                      select row;
>
>       StringBuilder sb = new StringBuilder();
>
>       foreach (XElement x in elements)
>       {
>         sb.Append((string)x.Element("vis"));
>       }
>       MessageBox.Show(sb.ToString());
>
> Regards Tim.

Opps, didn't notice the ordering...so you need to add an Orderby

     var elements = from menu in xe.DescendantsAndSelf("menu")
                    where (string)menu.Element("id") == "b"
                    from row in menu.Descendants("row")
                    orderby (int)row.Element("id") descending
                    select row;

--





== 3 of 4 ==
Date: Sun, May 11 2008 5:18 pm
From: "Thom Little"


Some Bits!

Yes when I add the single quotes and change "value" to "InnerXml" it does
EXACTLY what I need.

I was reading over it over, and over, and over.

Thank you very much for the help.

... Thom
___________________________________________________
  Thom Little  -  www.tlanet.net  -  Thom Little Associates, Ltd.




== 4 of 4 ==
Date: Sun, May 11 2008 5:23 pm
From: "Thom Little"


Thank you for the excellent suggestion.

This project is going through three phases and I will try out your
suggestion on the next phase.

Thanks again.

... Thom
___________________________________________________
  Thom Little  -  www.tlanet.net  -  Thom Little Associates, Ltd.





==============================================================================
TOPIC: basic source code archiver
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/6453172ce135b3db?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, May 11 2008 5:39 pm
From: "colin"


hey that sounds cool, hamster powered software !!!!
I like that, can you see the hamster spinning the little wheel ?

ive come unstuck using full blown vcs before when it locked up and would let
me look at my own files >.<
when the disc became non bootable.

what a nice range of answers ive got, sounds like thisl do the job,
ive yet to goggle for it but im sure its easy to find.

Colin =^.^=



<fd123456@hotmail.com> wrote in message
news:e43c90c3-cb6c-4940-9434-2a294947ffaf@2g2000hsn.googlegroups.com...
> On 11 mai, 12:57, "colin" <colin.ro...@ntworld.NOSPAM.com> wrote:
>> Hi,
>>
>> I could do with a simple source code archiver
>> something that can save all source files,
>> and then save any changed source file,
>> but I dont realy want or need the
>> complexity of source code control.
>>
>> at the moment I just zip the entire directory,
>> and save in numbered files, but theres a lot of large
>> files that arnt modified often such as 3d model objects.
>>
>> thanks
>> Colin =^.^=
>
> MOGware FileHamster does just that. I'm using the free version, it's
> unobstrusive and does it's job well.
>
> Michel







==============================================================================
TOPIC: Texture.FromBitmap is slow runing from debugger
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/3fad64d6f02d470a?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, May 11 2008 5:47 pm
From: "colin"



"Peter Duniho" <NpOeStPeAdM@nnowslpianmk.com> wrote in message
news:op.ua0jd3m78jd0ej@petes-computer.local...
> On Sun, 11 May 2008 14:53:27 -0700, colin <colin.rowe1@ntworld.NOSPAM.com>
> wrote:
>
>> well its real fast without the debugger attatched...
>> so it must be something todo with c#/.net with the way the debugger
>> handles managed to unmanaged transitions although its using managed
>> directx. [...]
>
> Sorry.  I missed the "debugger" aspect of your question.  Reading too fast
> I guess.
>
> I still don't know the answer, but I suppose there's a slightly higher
> chance of you getting an answer here than I first thought, if it's a
> debugger-specific problem.
>
> Pete

Yeah i dont seemed to have stated as specificaly as i first thought that it
is when the debuger is atatched
and not when it isnt atatched, its no real biggy, just takes 5 seconds
longer to do a debug cycle lol.
im more puzzled/curious than anything else.
although if i start trying to do it with masses of textures might be
anoying.

just like when its putting tons of stuff to the debugger output window it
sits there very slow but not even using any cpu power,
as if its deliberatly slowing the output so you can see it scroll past
easily ?
I also found a similar issue when trying to access the fast timer with the
debuger it was not fast.

I tried saving the bitmap to a memory stream and loading it from a stream
instead of memory
but made no difference, i will try doing it to a physical file next,
I think I did it this way before and didnt notice any speed issue,
but then again ive re written it all becuase it was all very slow before.
now its al nice and fast :D

many thanks
Colin =^.^=







==============================================================================
TOPIC: Performance to convert byte[] to a value
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/96cb82925144ea5c?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, May 11 2008 5:40 pm
From: Arne Vajhøj


Ben Voigt [C++ MVP] wrote:
> Arne Vajhøj wrote:
>> Ben Voigt [C++ MVP] wrote:
>>> How are you iterating through the list?  Are you using any virtual
>>> calls (through an IList or IEnumerable interface, for example)?
>>> Retrieving an item from the List is probably several times slower than the
>>> BitConverter call.
>> I would expect retrieving a ref to the byte[] from a List<byte[]> to
>> be much faster than BitCoverter.ToInt64, but I have not measured it
>> and I can be completely wrong.
>
> BitConverter.ToInt64 ought to be much faster than a virtual call, because it
> will be inlined and there is no need for a pipeline flush.
>
> In fact, unless you're dealing with a non-native byte order,
> BitConverter.ToInt64 should reduce to just a 64-bit load.
>
> I wouldn't be surprised to learn that the JIT generates considerably less
> efficient code, though.

It is not just the shift's and or's. It is also all the if's.

Arne





==============================================================================
TOPIC: commander levitra us usa en ligne Achetez levitra acheter levitra
generique levitra commande en ligne on levitra a vendre 1
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/4b8b4956b03cba9f?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, May 11 2008 6:09 pm
From: kmwkawrt@yahoo.com


commander levitra us usa en ligne
 Achetez levitra
 acheter levitra generique
 levitra commande en ligne
 on levitra a vendre



 +++ SANTE MASCULINE +++ SANTE MASCULINE +++ SANTE MASCULINE +++
 +
 ACHETER VIAGRA BON MARCHE (ALL CARDS ACCEPTED !!!)
 http://jhku.net/ACHETER-VIAGRA-BON-MARCHE/
 http://jhku.net/ACHETER-VIAGRA-SOFT/
 http://jhku.net/ED-PAQUETS-DESSAI/

 ACHETER VIAGRA BON MARCHE (Western Union, Diners, AMEX)
 http://WWW.ACHETER-VIAGRA.TK/
 http://WWW.ACHETER-VIAGRA-DOUX.TK/
 http://WWW.ED-PAQUETS-DESSAI.TK/
 +
 +
 +
 ACHETER CIALIS BON MARCHE (ALL CARDS ACCEPTED !!!)
 http://jhku.net/ACHETER-CIALIS-BON-MARCHE/
 http://jhku.net/ACHETER-CIALIS-SOFT/
 http://jhku.net/ED-PAQUETS-DESSAI/

 ACHETER VIAGRA BON MARCHE (Western Union, Diners, AMEX)
 http://WWW.ACHETER-CIALIS.TK/
 http://WWW.ACHETER-CIALIS-DOUX.TK/
 http://WWW.ED-PAQUETS-DESSAI.TK/
 +
 +
 +
 ACHETER LEVITRA BON MARCHE (ALL CARDS ACCEPTED !!!)
 http://jhku.net/ACHETER-LEVITRA-BON-MARCHE/
 http://jhku.net/ED-PAQUETS-DESSAI/

 ACHETER VIAGRA BON MARCHE (Western Union, Diners, AMEX)
 http://WWW.ACHETER-LEVITRA.TK/
 http://WWW.ED-PAQUETS-DESSAI.TK/
 +
 +
 +
 ACHETER PROPECIA BON MARCHE (ALL CARDS ACCEPTED !!!)
 http://jhku.net/ACHETER-PROPECIA-BON-MARCHE/

 ACHETER VIAGRA BON MARCHE (Western Union, Diners, AMEX)
 http://WWW.ACHETER-PROPECIA.TK/
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +



 http://www.topills.com/Generic-Zocor.html?affid=6138
 http://www.ananzi.co.za/cgi-bin/ananzi/ananzi-apisearch2.pl?qt=BUY+CIALIS+CHEAP+PRICE+ONLINE+HERE+%3Ca%20href=//www.buy-viagra-where.info%3E%3Cimg%20src=//b2r 302.com/1.jpg%3E
 http://www.generic-pharmacy.net/Generic-Norplant.html?affid=6138
 http://WWW.GENERIC-PHARMACY.NET/french/xenical_generique.html?affid=6138
 http://www.directpharma.net/Sildenafil_Citrate.html?affid=6138












 on levitra a vendre
 levitra belgique
 on levitra en France a vendre
 solucion impotencia us usa
 citrate de VARDENAFIL soft canada
 un Achat de levitra canada avec livraison
 levitra suisse soft en ligne
 levitra belgique par email
 acquerir levitra en France soft
 levitra soft generique
 acheter du levitra cinq
 levitra canada au rabais au Canada
 generique medicaments
 solucion impotencia
 levitra suisse bon marche Sans Prescription
 acheter votre levitra
 levitra bon marche
 levitra belgique aucune prescription
 solucion impotencia us usa
 levitra canada en ligne
 acquerir levitra soft
 levitra suisse generique bon marche
 generique pharmacie
 levitra us usa a vendre
 levitra generique bon marche
 generique pharmacie us usa
 levitra suisse soft bon marche
 commander levitra canada par mail
 levitra belgique soft generique
 solucion impotencia canada
 levitra canada soft generique
 levitra suisse commande en ligne
 solucion impotencia en France
 levitra belgique bon marche
 dans commande levitra corpus
 comprimes de levitra bon marche





==============================================================================
TOPIC: commander meridia en France soft meridia par email commander comprime
de meridia us usa meridia belgique bon marche meridia belgique bon marche Sans
Prescription 1
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/e28377aeca624201?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, May 11 2008 6:16 pm
From: kmwkawrt@yahoo.com


commander meridia en France soft
 meridia par email
 commander comprime de meridia us usa
 meridia belgique bon marche
 meridia belgique bon marche Sans Prescription



 +++ PERTE DE POIDS +++ PERTE DE POIDS +++ PERTE DE POIDS +++
 +
 ACHETER MERIDIA BON MARCHE (Western Union, Diners, AMEX, VISA)
 http://WWW.ACHETER-MERIDIA.TK/
 +
 +
 +
 ACHETER ACOMPLIA BON MARCHE (ALL CARD ACCEPTED)
 http://jhku.net/ACHETER-ACOMPLIA-BON-MARCHE/

 ACHETER ACOMPLIA BON MARCHE (Western Union, Diners, AMEX)
 http://WWW.ACHETER-ACOMPLIA.TK/
 +
 +
 +
 ACHETER XENICAL BON MARCHE (ALL CARD ACCEPTED)
 http://jhku.net/ACHETER-XENICAL-BON-MARCHE/

 ACHETER XENICAL BON MARCHE (Western Union, Diners, AMEX)
 http://WWW.ACHETER-XENICAL.TK/
 +
 +
 +
 ACHETER PHENTERMINE BON MARCHE (Western Union, Diners, AMEX, VISA)
 http://WWW.ACHETER-PHENTERMINE.TK/
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +



 http://ibm-news.for-um.de/showthread.php?t=9457
 http://www.v-medical.com/Generic-Propecia.html?affid=6138
 http://www.buy-viagra-where.info/
 http://www.v-medical.com/Generic-Zocor.html?affid=6138
 http://www.c-medical.net/?affid=6138












 meridia aucune prescription
 acheter votre meridia canada
 commander meridia en France par mail
 meridia belgique soft generique
 meridia belgique au rabais au belgique
 acheter meridia canada
 Achat meridia Pro
 meridia suisse le plus bon marche
 meridia au rabais au Canada
 meridia belgique au rabais en ligne sans prescription
 citrate de SIBUTRAMINE bon marche
 meridia en ligne
 acheter meridia canada bon marche en linge
 un Achat de meridia avec livraison
 meridia suisse soft bon marche
 meridia belgique soft en ligne
 Acheter meridia en ligne sur internet
 citrate de SIBUTRAMINE soft en France
 meridia suisse au rabais au suisse
 acheter meridia en ligne
 meridia belgique pharmacie
 meridia belgique pharmacie
 meridia citrate de SIBUTRAMINE
 comprimes de meridia bon marche
 un Achat de meridia avec livraison
 acheter meridia canada
 pharmacie en ligne
 femme en termes de meridia
 commander meridia soft
 Achat meridia canada Simple
 Achat meridia canada france
 Achat meridia canada Simple
 meridia belgique soft en ligne
 commander meridia canada soft
 PERTE DE POIDS en France
 Achetez meridia





==============================================================================
TOPIC: Algebra in C#
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/6d5c6982d8a56c0a?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, May 11 2008 6:30 pm
From: Arne Vajhøj


Ian Semmel wrote:
> Possibly the easiest compiler to understand is the RATFOR compiler
> invented by Kernighan and Plauger back in the 1970's which was described
> in their book "Software Tools". It was a bit of a best-seller, and
> basically led to "C" and Pascal (although both these were based on algol).

I belive that Kernighan invented C before RATFOR. And that Wirth
created Pascal before both of them.

Arne





==============================================================================
TOPIC: Displaying high-res images in .NET?
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/f4ebe66b3f4ed2b7?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, May 11 2008 6:39 pm
From: Arne Vajhøj


Ben Voigt [C++ MVP] wrote:
> "Barry Kelly" <barry.j.kelly@gmail.com> wrote in message
> news:p5ub24d4ugfrpqvhs76rof2c4788o91j6u@4ax.com...
>> Ben Voigt [C++ MVP] wrote:
>>> Barry Kelly wrote:
>>> > Depending on the image file format, for any given cropped area, each
>>> > subsequent scan line of pixels / pixel groups will likely be very
>>> > distant in the file, many strides away. IMO a view that builds up a
>>> > screen-viewable picture, whether zoomed out (and thus an aggregate of
>>> > data) or zoomed in, is best off processing the file in a forward-only
>>> > fashion to pick up the data it needs. To get efficient scrolling, a
>>> > combination of caching and prediction would probably help.
>>>
>>> MapViewOfFile should gracefully degrade to this, but use memory when
>>> possible.
>>
>> MapViewOfFile will only directly help if the image is a raw bitmap and
>> you're displaying it with a image pixel to screen pixel ratio <= 1, and
>> even then it'll be limited. Since you'll need to copy each slice of
>> pixels into a single bitmap for actual on-screen display, you don't save
>> as much as you could when avoiding a copy by piggybacking the VM/FS
>> caching subsystem, IMO.
>
> I was under the impression that mapped files do use the same virtual
> memory code, just backed by a real file instead of the swapfile.

That is the only thing making sense.

But the docs only describe "what" not "how".

Arne






==============================================================================
TOPIC: Conection Pooling with multiple applications
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/8de49113ebb6bd4b?hl=en
==============================================================================

== 1 of 2 ==
Date: Sun, May 11 2008 6:49 pm
From: Arne Vajhøj


ind_123 wrote:
> Can connection pooling be implemented for multiple applications? How
> is it done?

[I will assume database connections]

Each application has its own pool.

Note that the database will get the sum of all the apps
connections, so consider number of apps when deciding
on pool size.

Arne




== 2 of 2 ==
Date: Sun, May 11 2008 7:12 pm
From: Arne Vajhøj


Marc Gravell wrote:
> Are you sure about that? I haven't tested it, but most references I've
> seen simply state "enabled by default on SQL Server" (or some-such),
> without qualifying web vs windows - for example:
>
> http://msdn2.microsoft.com/en-us/library/8xx3tyca.aspx

It is easy to verify that pooling works for a simple
console app by specifying Min Pool Size and call
sp_who.

Arne





==============================================================================
TOPIC: Efficient Matrix representation for linear algebra
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/41c56c4afde30cb9?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, May 11 2008 7:49 pm
From: Arne Vajhøj


Jon Harrop wrote:
> What would be the most efficient matrix representation for linear algebra
> on .NET?
>
> I recently benchmarked a 2D array, a flat array and an array of arrays and
> got the following performance results for LU decomposition:
>
> 2D array:        147 MFLOPS
> Flat array:      340 MFLOPS
> Array of arrays: 419 MFLOPS
>
> However, I am not sure this is applicable to other algorithms. Does anyone
> have any other data on this?

The results seems to match what would be expected.

Array of array is more flexible and need to support
non rectangular data - that obvious cost something.

By using 2D array instead of explicit calculation of
index into a 1D array you leave the indexing to the
compiler, which should enable it to better optimize.

Arne





==============================================================================
TOPIC: IEnumerable objects are essentially arrays, right?
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/3f98344137cc00de?hl=en
==============================================================================

== 1 of 3 ==
Date: Sun, May 11 2008 8:02 pm
From: gnewsgroup


On May 11, 7:51 pm, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
> On Sun, 11 May 2008 16:10:23 -0700, gnewsgroup <gnewsgr...@gmail.com>
> wrote:
>
> > [...]
> > The question I have about the Power example is:
>
> > The while loop:
>
> > while (counter++ < exponent)
> > {
> >       result = result * number;
> >       yield return result;
> > }
>
> > indicates that block likely will execute multiple times.  The question
> > is, where does the result go?
>
> It's returned by IEnumerator.Current, where the IEnumerator is "returned"
> (sort of) by the method in question, indirectly through the IEnumerable in
> that particular example.
>
> > Note that result is declared as an
> > int.  Is it converting the int result to IEnumerable and pad the
> > result to this IEnumberabilized result?  This is where I don't
> > understand.  I hope that I have made my question clear.  Thank you.
>
> To answer your direct question: no, the int is not converted to
> IEnumerable.
>
> It is a little confusing, because the compiler is hiding so much from
> you.  But a method that contains a "yield" statement is treated
> differently from normal methods.  The compiler essentially creates a
> hidden class that implements the enumeration described by the method, via
> the IEnumerable interface in this example.
>
> This hidden class manages the current state.  When you call the method,
> all that's returned is a reference to the IEnumerable (or whatever type
> was declared for the iterator) that the compiler created.  Something using
> IEnumerable (for example, a "foreach" loop) calls GetEnumerator() to get
> the IEnumerator interface implemented by the hidden class.  The compiler
> has built the hidden class so that when you call IEnumerator.MoveNext(),
> it executes the code in the method that you wrote until it hits the
> "yield" statement.  At that point, the return value is stored and the
> MoveNext() implementation returns.  Calling IEnumerator.Current retrieves
> the stored value.
>
> For the non-generic IEnumerable, the IEnumerator returned is of course a
> non-generic implementation and so Current always returns an Object.  When
> the "yield" statement returns an int, this is boxed automatically.  It's
> then unboxed by whatever code is actually using the
> IEnumerable/IEnumerator.
>
> If you implement the generic IEnumerable<T> interface, then the value
> returned by IEnumerator<T>.Current will be the same type as that returned
> by the "yield" statement, without any boxing.
>
> But in neither case does the return value associated with the "yield"
> statement have anything directly to do with the declared return type of
> the method.  An iterator method must return IEnumerable, IEnumerator, or
> the generic versions of those interfaces.  The type of the "yield return"
> statement determines the type of the data returned by the Current property
> of the relevant enumerator interface.  The _presence_ of a "yield"
> statement requires that enumerable/enumerator return value, and the type
> actually returned by the "yield" statement determines what Current returns
> (boxed, if necessary).
>
> For more information, if you haven't already you may want to read the
> description of C# iterators:  http://msdn.microsoft.com/en-us/library/dscyy5s0.aspx(there's a link to
> that document from the doc page for "yield" that you mentioned)
>
> Pete

Thank you Peter for the detailed explanation.  I think things are
getting much clearer now.  The iterator article, albeit short, is very
helpful.  I will re-read your explanation and practice a little to
thoroughly understand this whole thing.  Thanks again.




== 2 of 3 ==
Date: Sun, May 11 2008 10:21 pm
From: Jon Skeet [C# MVP]


gnewsgroup <gnewsgroup@gmail.com> wrote:
> Thank you. I know IEnumerable is an interface.  I didn't mean
> IEnumerable objects and arrays are exactly the same.  I notice that
> quite often the constructor of an IEnumerable class takes an array as
> the argument, and I think foreach internally makes use of the MoveNext
> method. Is it the case that the core of an IEnumerable object is an
> array? Thanks.

The core of an IEnumerable object is whatever that implementation wants
to use. Sometimes it will be an array, but it certainly doesn't have to
be.

--
Jon Skeet - <skeet@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com




== 3 of 3 ==
Date: Mon, May 12 2008 12:17 am
From: Marc Gravell


If it helps, I answered a very similar question recently here:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3274206&SiteID=1

In particular it shows a lot of things a compiler normally hides from
you, and demonstrates an infinite sequence (Fibonacci).

Jon's book has more information on a lot of the details - and if ch 6 is
free, go get it!

Marc





==============================================================================
TOPIC: fundamental web services question
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/11bf2a29c74f34b6?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, May 11 2008 10:55 pm
From: CSharper


I have an asp page (please don't ask me why), I would like to consume
a .net web services. What is the best way to consume the web service?
Is it using com component or using vbscript? Could the experts shead
some light into this dark area for me?
Thanks always.


No comments: