dotnet 1.1 vs 2.0 (best replacement for List<int> in 1.1)

P

per9000

Hi,

I wanted to test to compile an application I build for .NET 2.0 in
with the 1.1 C# compiler. I encountered difficulties since I had a
List<myClass>. I found a list of what is new in .NET 2.0 and generics
is on it - I assume this is why I encounter problems. So this raises a
number of questions:

- What is the best replacement of List<int> in 1.1 (or is the list
just in another namespace)?
- Why should I use .NET 2.0 (or 3.0 (or any other future version)) if
my application compiles under 1.1?
- Will future releases of .NET be backwards-compatible (f.x: will
my .NET 2.0 application be useable under .NET 13.37 in 20 years)?

Thanks,
Per
 
C

ClayB

You can use ArrayList in 1.1 to mimic a List<int>.

public class IntList : ArrayList
{
public new int this[int i]
{
get
{
if (i < 0 || i >= base.Count || base == null)
throw new ArgumentException("Invalid index value.");
return (int)base;
}
set
{
if (i > -1 && i < base.Count)
{
base = value;
}
}
}
}
=============
Clay Burch
Syncfusion, Inc.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

per9000 said:
Hi,

I wanted to test to compile an application I build for .NET 2.0 in
with the 1.1 C# compiler. I encountered difficulties since I had a
List<myClass>. I found a list of what is new in .NET 2.0 and generics
is on it - I assume this is why I encounter problems. So this raises a
number of questions:

Unless you have a GOOD reason I dont recommend it. There will be a number of
new features (as well as methods) that do not exist in 1.1

Why you want to do this anyway?

Answering you question you have two options:
1- Use ArrayList and cast it when needed
2- Use a strongtyped collection (you will need to write new code for this)
 
N

not_a_commie

- What is the best replacement of List said:
just in another namespace)?

Use System.Collections.Generic.List in .NET 2.0 or 3.0. Inherit from
it if needed.
- Why should I use .NET 2.0 (or 3.0 (or any other future version)) if
my application compiles under 1.1?

If your application is done and not needing to be maintained, then
don't. However, .NET 2.0 does do some nice things with generics/
templates that come in handy. Both 1.1 and 2.0 have lots of bugs in
double buffering of controls that are fixed in the WPF (3.0).
- Will future releases of .NET be backwards-compatible (f.x: will
my .NET 2.0 application be useable under .NET 13.37 in 20 years)?

If more than 25% of the code needs to be replaced, you're better to
rewrite the whole app. Hopefully that will happen at least every five
years. I would guess you will have at least five years overlap of
compatibility.
 
D

Dustin Campbell

- What is the best replacement of List said:
Use System.Collections.Generic.List in .NET 2.0 or 3.0. Inherit from
it if needed.

It is best to inherit from System.Collections.ObjectModel.Collection<T> in
..NET 2.0 instead of List<T>. Collection<T> is intended to be descended from
and provides virtual methods that can be overridden to better customize the
collection.

Best Regards,
Dustin Campbell
Developer Express Inc.
 
P

per9000

Thanks all for the nice replies.

Well, first of all our application is already written (compiles
in .NET 2) and targets windows/.NET 2+ at the moment. Out of curiosity
I wanted to try .NET 1.1 - as I understand it this is where MONO is
right now. If we could rewrite a few hundred lines of code and reach
Mac + Gnu/Unix/Linux (+ Win/MONO) that might be nice.

Also I intend to sniff around the .NET Compact Framework (but I
haven't looked at it yet) just for fun (and to learn about the
differences).

Do you guys have any experience in working with both .NET and MONO?

Cheers,
Per
 
J

Jon Skeet [C# MVP]

per9000 said:
Thanks all for the nice replies.

Well, first of all our application is already written (compiles
in .NET 2) and targets windows/.NET 2+ at the moment. Out of curiosity
I wanted to try .NET 1.1 - as I understand it this is where MONO is
right now. If we could rewrite a few hundred lines of code and reach
Mac + Gnu/Unix/Linux (+ Win/MONO) that might be nice.

Also I intend to sniff around the .NET Compact Framework (but I
haven't looked at it yet) just for fun (and to learn about the
differences).

Do you guys have any experience in working with both .NET and MONO?

Mono has a great deal of the .NET 2.0 stuff already - and in
particular, I'm sure it supports generic collections. Why not try it
before going down to 1.1?
 
B

Bruce Wood

- Will future releases of .NET be backwards-compatible (f.x: will
my .NET 2.0 application be useable under .NET 13.37 in 20 years)?

Most likely not. With every release Microsoft deprecates some classes
and methods. I find it hard to believe that they would maintain
backward compatibility for 20 years.

In particular, how long will MS maintiain GDI / GDI+ style graphics
interaction once WPF becomes common? I figure 5 years at best.

That means not only recompilation, but the odd change here and there
to update your application to use new paradigms within Windows,
probably every 5 years or so. Of course, that all depends upon what
kinds of bleeding-edge features you're using. I doubt that ArrayList
will ever go away, or that methods will suddenly be called in a new
and incompatible way. More likely the way that you interact with the
UI, output devices, storage devices, etc. will change over time, and
you'll have to modify your program to keep up.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top