Hi
When C# 2.0 arrives System.Collections.Specialized.StringCollection will
become "obsolete". Will the framework still contain this class, or will
there be a C# 1.X to 2.0 conversion utility that will change
System.Collections.Specialized.StringCollection to
System.Collections.ArrayList <string> and ArrayList to ArrayList<object>
??
Gary 24 1671
SADLY (so to say) the old non-generic collections are still there.
Which just keeps, porapbly, existing bugs around.
Thomas Tomiczek
THONA Software & Consulting Ltd.
(Microsoft MVP C#/.NET)
"Gary van der Merwe" <ga*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl... Hi
When C# 2.0 arrives System.Collections.Specialized.StringCollection will become "obsolete". Will the framework still contain this class, or will there be a C# 1.X to 2.0 conversion utility that will change System.Collections.Specialized.StringCollection to System.Collections.ArrayList <string> and ArrayList to ArrayList<object> ??
Gary
Hi
Are there new generic collections?
Gary
"Thomas Tomiczek (MVP)" <t.********@thona-consulting.com> wrote in message
news:O7**************@TK2MSFTNGP09.phx.gbl... SADLY (so to say) the old non-generic collections are still there.
Which just keeps, porapbly, existing bugs around.
Thomas Tomiczek THONA Software & Consulting Ltd. (Microsoft MVP C#/.NET)
"Gary van der Merwe" <ga*****@hotmail.com> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl... Hi
When C# 2.0 arrives System.Collections.Specialized.StringCollection will become "obsolete". Will the framework still contain this class, or will there be a C# 1.X to 2.0 conversion utility that will change System.Collections.Specialized.StringCollection to System.Collections.ArrayList <string> and ArrayList to
ArrayList<object> ??
Gary
What they should do is label them as obsolete in a compiler warning and then
recommend using the Generics collection.
If its in the ECMA spec its gotta be supported. (then again the spec there
isnt final yet. Can anybody submit proposals for the C# ECMA comittee?)
Why isnt VB going for ECMA, to me if its not , its propriety closed language
and wont be used here, after all they just are runing VB6 until end of life
now which is 31-Mar-2005 when VB6 = offically dead. (from
support.microsoft.com)
Until its standardized, those languages wont be used here.
"Gary van der Merwe" <ga*****@hotmail.com> wrote in message
news:uu**************@TK2MSFTNGP10.phx.gbl... Hi
Are there new generic collections?
Gary
"Thomas Tomiczek (MVP)" <t.********@thona-consulting.com> wrote in message news:O7**************@TK2MSFTNGP09.phx.gbl... SADLY (so to say) the old non-generic collections are still there.
Which just keeps, porapbly, existing bugs around.
Thomas Tomiczek THONA Software & Consulting Ltd. (Microsoft MVP C#/.NET)
"Gary van der Merwe" <ga*****@hotmail.com> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl... Hi
When C# 2.0 arrives System.Collections.Specialized.StringCollection
will become "obsolete". Will the framework still contain this class, or
will there be a C# 1.X to 2.0 conversion utility that will change System.Collections.Specialized.StringCollection to System.Collections.ArrayList <string> and ArrayList to ArrayList<object> ??
Gary
On Tue, 11 Nov 2003 14:26:57 +0100, "Thomas Tomiczek \(MVP\)"
<t.********@thona-consulting.com> wrote: SADLY (so to say) the old non-generic collections are still there.
Which just keeps, porapbly, existing bugs around.
Well, I haven't noticed any bugs in StringCollection so far, and
besides they could re-implement it as a pre-created generic collection
in .NET 2.0, couldn't they?
-- http://www.kynosarges.de
Hi
I think the refrence to bugs was regarding the fact that the old collections
are slow because you have to continualy box objects.
Gary
"Christoph Nahr" <ch************@kynosarges.de> wrote in message
news:ek********************************@4ax.com... On Tue, 11 Nov 2003 14:26:57 +0100, "Thomas Tomiczek \(MVP\)" <t.********@thona-consulting.com> wrote:
SADLY (so to say) the old non-generic collections are still there.
Which just keeps, porapbly, existing bugs around.
Well, I haven't noticed any bugs in StringCollection so far, and besides they could re-implement it as a pre-created generic collection in .NET 2.0, couldn't they? -- http://www.kynosarges.de
A generic wouldn't solve the problem of the speed of boxing, would it? I
haven't read about how they are implemented, but I would think that integers
would still have to be treated a objects by the generic.
Keith Patrick <ri*******************@hotmail.com> wrote: A generic wouldn't solve the problem of the speed of boxing, would it? I haven't read about how they are implemented, but I would think that integers would still have to be treated a objects by the generic.
I don't believe so. I believe each generic class is compiled into a
type-specific class when it's first used, and that can take advantage
of anything type-specific such as size. (Note that this *isn't* the way
generics will be working in Java, AFAIK.)
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Hi
No. Thats the whole point of them. With Generics, the type checking happens
when you complile, not at runtime.
To can get the spec here : http://download.microsoft.com/downlo...e-9e5e-f87a44a
f3db9/SpecificationVer2.doc
Gary
"Keith Patrick" <ri*******************@hotmail.com> wrote in message
news:ec**************@TK2MSFTNGP12.phx.gbl... A generic wouldn't solve the problem of the speed of boxing, would it? I haven't read about how they are implemented, but I would think that
integers would still have to be treated a objects by the generic.
Gary van der Merwe <ga*****@hotmail.com> wrote: No. Thats the whole point of them. With Generics, the type checking happens when you complile, not at runtime.
That doesn't *necessarily* get rid of boxing though. For instance, in
the Java implementation of generics, the casting will be (largely)
removed, but boxing won't be.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Hi Jon
What is the difference between Boxing and Casting?
Gary
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om... Gary van der Merwe <ga*****@hotmail.com> wrote: No. Thats the whole point of them. With Generics, the type checking
happens when you complile, not at runtime.
That doesn't *necessarily* get rid of boxing though. For instance, in the Java implementation of generics, the casting will be (largely) removed, but boxing won't be.
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
"Keith Patrick" <ri*******************@hotmail.com> wrote in message
news:ec**************@TK2MSFTNGP12.phx.gbl... A generic wouldn't solve the problem of the speed of boxing, would it? I haven't read about how they are implemented, but I would think that
integers would still have to be treated a objects by the generic.
Hi Keith,
In the September MSDN, Jason Clark writes about Generics. In the
Performance paragraph he states "This is because boxing of the values is
avoided completely.", but you should read the whole paragraph for context: http://msdn.microsoft.com/msdnmag/issues/03/09/NET/
There is also a follow-up article in the October edition that talks more
about the implementation: http://msdn.microsoft.com/msdnmag/issues/03/10/NET/
Joe
-- http://www.csharp-station.com
Gary van der Merwe <ga*****@hotmail.com> wrote: What is the difference between Boxing and Casting?
Boxing is what happens to make a reference-type value out of a value-
type value. For instance:
int i = 15;
object x = i;
The above creates a "boxed" int, and when you cast back to int it has
to unbox it.
When you cast between different reference types, or indeed between
different value types, there's no boxing or unboxing involved:
string s1 = "hello";
object o = s1;
string s2 = (string) o;
int i = 5;
byte b = (byte) i;
int j = b;
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
StringCollection doesn't have any boxing going on, but the other
object-based ones would suffer.
-mike
MVP
"Gary van der Merwe" <ga*****@hotmail.com> wrote in message
news:OS**************@TK2MSFTNGP10.phx.gbl... Hi
I think the refrence to bugs was regarding the fact that the old
collections are slow because you have to continualy box objects.
Gary
"Christoph Nahr" <ch************@kynosarges.de> wrote in message news:ek********************************@4ax.com... On Tue, 11 Nov 2003 14:26:57 +0100, "Thomas Tomiczek \(MVP\)" <t.********@thona-consulting.com> wrote:
SADLY (so to say) the old non-generic collections are still there.
Which just keeps, porapbly, existing bugs around.
Well, I haven't noticed any bugs in StringCollection so far, and besides they could re-implement it as a pre-created generic collection in .NET 2.0, couldn't they? -- http://www.kynosarges.de
Hmmm... I have been refering to casting as boxing }:-|
Thanks
Gary
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om... Gary van der Merwe <ga*****@hotmail.com> wrote: What is the difference between Boxing and Casting?
Boxing is what happens to make a reference-type value out of a value- type value. For instance:
int i = 15; object x = i;
The above creates a "boxed" int, and when you cast back to int it has to unbox it.
When you cast between different reference types, or indeed between different value types, there's no boxing or unboxing involved:
string s1 = "hello"; object o = s1; string s2 = (string) o;
int i = 5; byte b = (byte) i; int j = b;
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
For ValueTypes, a specialized type class is created. For RefTypes, only one
is created and it's reused. This solves the boxing issue (preliminary
results tell me it's at least 5 times faster in a tight loop that woult
otherwise box and unbox).
-mike
MVP
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om... Keith Patrick <ri*******************@hotmail.com> wrote: A generic wouldn't solve the problem of the speed of boxing, would it?
I haven't read about how they are implemented, but I would think that
integers would still have to be treated a objects by the generic.
I don't believe so. I believe each generic class is compiled into a type-specific class when it's first used, and that can take advantage of anything type-specific such as size. (Note that this *isn't* the way generics will be working in Java, AFAIK.)
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
Jon's answer is about Generics in general. The .NET implementation will
eliminate boxing (support at the IL level). The Java implementation doesn't
get around this.
-mike
MVP
"Joe Mayo" <jm***@ddiieessppaammeerrssddiiee.com> wrote in message
news:OM*************@tk2msftngp13.phx.gbl... "Keith Patrick" <ri*******************@hotmail.com> wrote in message news:ec**************@TK2MSFTNGP12.phx.gbl... A generic wouldn't solve the problem of the speed of boxing, would it?
I haven't read about how they are implemented, but I would think that integers would still have to be treated a objects by the generic.
Hi Keith,
In the September MSDN, Jason Clark writes about Generics. In the Performance paragraph he states "This is because boxing of the values is avoided completely.", but you should read the whole paragraph for context:
http://msdn.microsoft.com/msdnmag/issues/03/09/NET/
There is also a follow-up article in the October edition that talks more about the implementation:
http://msdn.microsoft.com/msdnmag/issues/03/10/NET/
Joe -- http://www.csharp-station.com
Hi
Dose the runtime casting from object -> string not cause performence
problems?
Would this improve with the use of generics?
Gary
"Michael Giagnocavo [MVP]" <mg*******@Atrevido.net> wrote in message
news:uW**************@tk2msftngp13.phx.gbl... StringCollection doesn't have any boxing going on, but the other object-based ones would suffer. -mike MVP
"Gary van der Merwe" <ga*****@hotmail.com> wrote in message news:OS**************@TK2MSFTNGP10.phx.gbl... Hi
I think the refrence to bugs was regarding the fact that the old collections are slow because you have to continualy box objects.
Gary
"Christoph Nahr" <ch************@kynosarges.de> wrote in message news:ek********************************@4ax.com... On Tue, 11 Nov 2003 14:26:57 +0100, "Thomas Tomiczek \(MVP\)" <t.********@thona-consulting.com> wrote:
>SADLY (so to say) the old non-generic collections are still there. > >Which just keeps, porapbly, existing bugs around.
Well, I haven't noticed any bugs in StringCollection so far, and besides they could re-implement it as a pre-created generic collection in .NET 2.0, couldn't they? -- http://www.kynosarges.de
On Tue, 11 Nov 2003 20:16:28 +0200, "Gary van der Merwe"
<ga*****@hotmail.com> wrote: Dose the runtime casting from object -> string not cause performence problems?
No. String is a reference type, so there's no boxing/unboxing going
on, so the performance penalty will be negligible. (At least compared
to what you'd have to pay for value types!)
-- http://www.kynosarges.de
Right, storing a reftype in an object costs nothing (whereas a boxing costs
quite a bit). A downcast costs about 4 times less than a box.
-mike
MVP
"Christoph Nahr" <ch************@kynosarges.de> wrote in message
news:1p********************************@4ax.com... On Tue, 11 Nov 2003 20:16:28 +0200, "Gary van der Merwe" <ga*****@hotmail.com> wrote:
Dose the runtime casting from object -> string not cause performence problems?
No. String is a reference type, so there's no boxing/unboxing going on, so the performance penalty will be negligible. (At least compared to what you'd have to pay for value types!) -- http://www.kynosarges.de
A bit of a clarification.
In the Java implementation, the casting will be removed from the user code,
but it will still be present at the bytecode level.
--
Eric Gunnerson
Visit the C# product team at http://www.csharp.net
Eric's blog is at http://blogs.gotdotnet.com/ericgu/
This posting is provided "AS IS" with no warranties, and confers no rights.
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om... Gary van der Merwe <ga*****@hotmail.com> wrote: No. Thats the whole point of them. With Generics, the type checking
happens when you complile, not at runtime.
That doesn't *necessarily* get rid of boxing though. For instance, in the Java implementation of generics, the casting will be (largely) removed, but boxing won't be.
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
Anders did some timings on this for his PDC presentation (which we're
working to get up on the C# dev center on MSDN).
IIRC, you save around 10% of the loop overhead in the reference type case
(by avoiding the cast), and something like 50% on the value type case. This
was for essentially empty loops.
--
Eric Gunnerson
Visit the C# product team at http://www.csharp.net
Eric's blog is at http://blogs.gotdotnet.com/ericgu/
This posting is provided "AS IS" with no warranties, and confers no rights.
"Michael Giagnocavo [MVP]" <mg*******@Atrevido.net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl... Right, storing a reftype in an object costs nothing (whereas a boxing
costs quite a bit). A downcast costs about 4 times less than a box. -mike MVP
"Christoph Nahr" <ch************@kynosarges.de> wrote in message news:1p********************************@4ax.com... On Tue, 11 Nov 2003 20:16:28 +0200, "Gary van der Merwe" <ga*****@hotmail.com> wrote:
Dose the runtime casting from object -> string not cause performence problems?
No. String is a reference type, so there's no boxing/unboxing going on, so the performance penalty will be negligible. (At least compared to what you'd have to pay for value types!) -- http://www.kynosarges.de
We certainly will not get rid of the existing types, as lots of programs
depend upon them.
We had talked about auto-migration, but it's somewhat unpalatable as we've
taken the opportunity to fix some problems with the ArrayList and Hashtable
classes, but the fixes might break existing code in some rare cases. In the
generics world, you'll use List<T> and Dictionary<K, V> instead.
--
Eric Gunnerson
Visit the C# product team at http://www.csharp.net
Eric's blog is at http://blogs.gotdotnet.com/ericgu/
This posting is provided "AS IS" with no warranties, and confers no rights.
"Gary van der Merwe" <ga*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl... Hi
When C# 2.0 arrives System.Collections.Specialized.StringCollection will become "obsolete". Will the framework still contain this class, or will there be a C# 1.X to 2.0 conversion utility that will change System.Collections.Specialized.StringCollection to System.Collections.ArrayList <string> and ArrayList to ArrayList<object> ??
Gary
I'd love to see his benchmarks. I did mine by adding an item on each
iteration (requiring a box in, or for a reftype, just passing the ref) and
then taking it back out.
The generics version for the reftypes was barely noticable (2**24
iterations, something like 0.02 seconds speed up). Of course, this was
actually doing some real work. I timed the actual cast down to about 3ns
(on a P4c 3GHz), so I'm saving that each time.
For valuetypes, it was a whole different story, the memory requirements got
so high they slowed it down immensely (2**24 objects, since each int was
boxed).
So for "real world" apps, I'd imagine we'll see great (runtime performance)
benefits for valuetypes and an almost unnoticeable improvement for
reftypes...
-mike
MVP
"Eric Gunnerson [MS]" <er****@online.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl... Anders did some timings on this for his PDC presentation (which we're working to get up on the C# dev center on MSDN).
IIRC, you save around 10% of the loop overhead in the reference type case (by avoiding the cast), and something like 50% on the value type case.
This was for essentially empty loops.
-- Eric Gunnerson
Visit the C# product team at http://www.csharp.net Eric's blog is at http://blogs.gotdotnet.com/ericgu/
This posting is provided "AS IS" with no warranties, and confers no
rights. "Michael Giagnocavo [MVP]" <mg*******@Atrevido.net> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl... Right, storing a reftype in an object costs nothing (whereas a boxing costs quite a bit). A downcast costs about 4 times less than a box. -mike MVP
"Christoph Nahr" <ch************@kynosarges.de> wrote in message news:1p********************************@4ax.com... On Tue, 11 Nov 2003 20:16:28 +0200, "Gary van der Merwe" <ga*****@hotmail.com> wrote:
>Dose the runtime casting from object -> string not cause performence >problems?
No. String is a reference type, so there's no boxing/unboxing going on, so the performance penalty will be negligible. (At least compared to what you'd have to pay for value types!) -- http://www.kynosarges.de
Michael,
Mind to share your code? My observations are on par with Anders timings.
Willy.
"Michael Giagnocavo [MVP]" <mg*******@Atrevido.net> wrote in message news:uJ**************@TK2MSFTNGP12.phx.gbl... I'd love to see his benchmarks. I did mine by adding an item on each iteration (requiring a box in, or for a reftype, just passing the ref) and then taking it back out.
The generics version for the reftypes was barely noticable (2**24 iterations, something like 0.02 seconds speed up). Of course, this was actually doing some real work. I timed the actual cast down to about 3ns (on a P4c 3GHz), so I'm saving that each time.
For valuetypes, it was a whole different story, the memory requirements got so high they slowed it down immensely (2**24 objects, since each int was boxed).
So for "real world" apps, I'd imagine we'll see great (runtime performance) benefits for valuetypes and an almost unnoticeable improvement for reftypes...
-mike MVP
"Eric Gunnerson [MS]" <er****@online.microsoft.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl... Anders did some timings on this for his PDC presentation (which we're working to get up on the C# dev center on MSDN).
IIRC, you save around 10% of the loop overhead in the reference type case (by avoiding the cast), and something like 50% on the value type case. This was for essentially empty loops.
-- Eric Gunnerson
Visit the C# product team at http://www.csharp.net Eric's blog is at http://blogs.gotdotnet.com/ericgu/
This posting is provided "AS IS" with no warranties, and confers no rights. "Michael Giagnocavo [MVP]" <mg*******@Atrevido.net> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl... Right, storing a reftype in an object costs nothing (whereas a boxing costs quite a bit). A downcast costs about 4 times less than a box. -mike MVP
"Christoph Nahr" <ch************@kynosarges.de> wrote in message news:1p********************************@4ax.com... > On Tue, 11 Nov 2003 20:16:28 +0200, "Gary van der Merwe" > <ga*****@hotmail.com> wrote: > > >Dose the runtime casting from object -> string not cause performence > >problems? > > No. String is a reference type, so there's no boxing/unboxing going > on, so the performance penalty will be negligible. (At least compared > to what you'd have to pay for value types!) > -- > http://www.kynosarges.de
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: mark |
last post by:
I've been getting odd compile errors when trying to sort while using
generics.
I have the following code:
static final List<Class> levelList;
static {
Vector<Class> v = new Vector<Class>();...
|
by: Helium |
last post by:
Is there any need for "System.Collections.Queue" any more? OK, .Net
made the mistake to start without generics, but that is fixed now.
Languages without support for generics could use...
|
by: Ruediger Klaehn |
last post by:
Sorry about the harsh language, but I have to vent my anger to somebody who
actually understands what I am talking about. Complaining to my girlfriend
is not going to produce any meaningful results...
|
by: Marc |
last post by:
Given a class 'Invoice' with a property 'public IMyColl<IInvoiceLine>
InvoiceLines' where 'IMyColl<T> : IList<T>' i would like to detect by
reflection that 'InvoiceLines' is a...
|
by: nick_nw |
last post by:
Hi,
What significant advantages do generics give me over passing objects
around as 'object' and casting when needed?
I was asked this recently and started off by saying, "well of course...
|
by: Showjumper |
last post by:
Back in asp.net 1.1 i made custom collection classes per Karl Seguin's
article On the Way to Mastering ASP.NET: Introducing Custom Entity Classes
to take advantage of strongly typed data. Now with...
|
by: SHEBERT |
last post by:
Here is an example of a SortedList that works as a datasource to the ComboBox
and a generic SortedList<that does not works as a datasource to the
ComboBox.
Why? If I use List and generic List<>,...
|
by: Mark Rae |
last post by:
Hi,
I'm in the process of updating an ASP.NET v1.1 web app to v2. The app uses
ActiveDirectory a great deal, and I'm trying to use the new
System.Collections.Generic namespace where possible,...
|
by: SpotNet |
last post by:
Hello NewsGroup,
Reading up on Generics in the .NET Framework 2.0 using C# 2005 (SP1), I have
a question on the application of Generics. Knowingly, Generic classes are
contained in the...
|
by: =?Utf-8?B?Q29kZVJhem9y?= |
last post by:
Can someone explain a few things about collections to me.
In C# 2 generics, you can create a collection class by inheriting from
System.Collections.ObjectModel.Collection. Using this you can...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |