on arrete pas de le dire : pas de ArrayList.
passer à 2005 et generics, ou generer ses classes en utilisant ce modele
en 2003 :
using System;
using System.Collections;
namespace Test
{
/// <summary>
/// A collection that stores <see cref='Dummy'/> objects.
/// </summary>
[Serializable()]
public class DummyCollection : CollectionBase {
/// <summary>
/// Initializes a new instance of <see cref='DummyCollection'/>.
/// </summary>
public DummyCollection()
{
}
/// <summary>
/// Initializes a new instance of <see cref='DummyCollection'/> based
another <see cref='DummyCollection'/>.
/// </summary>
/// <param name='val'>
/// A <see cref='DummyCollection'/> from which the contents are copied
/// </param>
public DummyCollection(DummyCollection val)
{
this.AddRange(val);
}
/// <summary>
/// Initializes a new instance of <see cref='DummyCollection'/>
containing any array of <see cref='Dummy'/> objects.
/// </summary>
/// <param name='val'>
/// A array of <see cref='Dummy'/> objects with which to intialize
the collection
/// </param>
public DummyCollection(Dummy[] val)
{
this.AddRange(val);
}
/// <summary>
/// Represents the entry at the specified index of the <see
cref='Dummy'/>.
/// </summary>
/// <param name='index'>The zero-based index of the entry to locate in
collection.</param>
/// <value>The entry at the specified index of the collection.</value>
/// <exception cref='ArgumentOutOfRangeException'><paramref
is outside the valid range of indexes for the collection.</exception>
public Dummy this[int index] {
get {
return ((Dummy)(List[index]));
}
set {
List[index] = value;
}
}
/// <summary>
/// Adds a <see cref='Dummy'/> with the specified value to the
/// <see cref='DummyCollection'/>.
/// </summary>
/// <param name='val'>The <see cref='Dummy'/> to add.</param>
/// <returns>The index at which the new element was inserted.</returns>
/// <seealso cref='DummyCollection.AddRange'/>
public int Add(Dummy val)
{
return List.Add(val);
}
/// <summary>
/// Copies the elements of an array to the end of the <see
cref='DummyCollection'/>.
/// </summary>
/// <param name='val'>
/// An array of type <see cref='Dummy'/> containing the objects to
to the collection.
/// </param>
/// <seealso cref='DummyCollection.Add'/>
public void AddRange(Dummy[] val)
{
for (int i = 0; i < val.Length; i++) {
this.Add(val[i]);
}
}
/// <summary>
/// Adds the contents of another <see cref='DummyCollection'/> to the
end of the collection.
/// </summary>
/// <param name='val'>
/// A <see cref='DummyCollection'/> containing the objects to add to
the collection.
/// </param>
/// <seealso cref='DummyCollection.Add'/>
public void AddRange(DummyCollection val)
{
for (int i = 0; i < val.Count; i++)
{
this.Add(val[i]);
}
}
/// <summary>
/// Gets a value indicating whether the
/// <see cref='DummyCollection'/> contains the specified <see
cref='Dummy'/>.
/// </summary>
/// <param name='val'>The <see cref='Dummy'/> to locate.</param>
/// <returns>
/// <see langword='true'/> if the <see cref='Dummy'/> is contained in
collection;
/// otherwise, <see langword='false'/>.
/// </returns>
/// <seealso cref='DummyCollection.IndexOf'/>
public bool Contains(Dummy val)
{
return List.Contains(val);
}
/// <summary>
/// Copies the <see cref='DummyCollection'/> values to a
<see cref='Array'/> instance at the
/// specified index.
/// </summary>
/// <param name='array'>The one-dimensional <see cref='Array'/> that is
the destination of the values copied from <see
cref='DummyCollection'/>.</param>
/// <param name='index'>The index in <paramref name='array'/> where
copying begins.</param>
/// <exception cref='ArgumentException'>
/// <para><paramref name='array'/> is multidimensional.</para>
/// <para>-or-</para>
/// <para>The number of elements in the <see cref='DummyCollection'/>
greater than
/// the available space between <paramref name='arrayIndex'/>
the end of
/// <paramref name='array'/>.</para>
/// </exception>
/// <exception cref='ArgumentNullException'><paramref name='array'/> is
<see langword='null'/>. </exception>
/// <exception cref='ArgumentOutOfRangeException'><paramref
name='arrayIndex'/> is less than <paramref name='array'/>'s lowbound.
</exception>
/// <seealso cref='Array'/>
public void CopyTo(Dummy[] array, int index)
{
List.CopyTo(array, index);
}
/// <summary>
/// Returns the index of a <see cref='Dummy'/> in
/// the <see cref='DummyCollection'/>.
/// </summary>
/// <param name='val'>The <see cref='Dummy'/> to locate.</param>
/// <returns>
/// The index of the <see cref='Dummy'/> of <paramref name='val'/> in
the
/// <see cref='DummyCollection'/>, if found; otherwise, -1.
/// </returns>
/// <seealso cref='DummyCollection.Contains'/>
public int IndexOf(Dummy val)
{
return List.IndexOf(val);
}
/// <summary>
/// Inserts a <see cref='Dummy'/> into the <see
at the specified index.
/// </summary>
/// <param name='index'>The zero-based index where <paramref
should be inserted.</param>
/// <param name='val'>The <see cref='Dummy'/> to insert.</param>
/// <seealso cref='DummyCollection.Add'/>
public void Insert(int index, Dummy val)
{
List.Insert(index, val);
}
/// <summary>
/// Returns an enumerator that can iterate through the <see
cref='DummyCollection'/>.
/// </summary>
/// <seealso cref='IEnumerator'/>
public new DummyEnumerator GetEnumerator()
{
return new DummyEnumerator(this);
}
/// <summary>
/// Removes a specific <see cref='Dummy'/> from the <see
cref='DummyCollection'/>.
/// </summary>
/// <param name='val'>The <see cref='Dummy'/> to remove from the <see
cref='DummyCollection'/>.</param>
/// <exception cref='ArgumentException'><paramref name='val'/> is not
found in the Collection.</exception>
public void Remove(Dummy val)
{
List.Remove(val);
}
/// <summary>
/// Enumerator that can iterate through a DummyCollection.
/// </summary>
/// <seealso cref='IEnumerator'/>
/// <seealso cref='DummyCollection'/>
/// <seealso cref='Dummy'/>
public class DummyEnumerator : IEnumerator
{
IEnumerator baseEnumerator;
IEnumerable temp;
/// <summary>
/// Initializes a new instance of <see cref='DummyEnumerator'/>.
/// </summary>
public DummyEnumerator(DummyCollection mappings)
{
this.temp = ((IEnumerable)(mappings));
this.baseEnumerator = temp.GetEnumerator();
}
/// <summary>
/// Gets the current <see cref='Dummy'/> in the <seealso
cref='DummyCollection'/>.
/// </summary>
public Dummy Current {
get {
return ((Dummy)(baseEnumerator.Current));
}
}
object IEnumerator.Current {
get {
return baseEnumerator.Current;
}
}
/// <summary>
/// Advances the enumerator to the next <see cref='Dummy'/> of the
cref='DummyCollection'/>.
/// </summary>
public bool MoveNext()
{
return baseEnumerator.MoveNext();
}
/// <summary>
/// Sets the enumerator to its initial position, which is before the
first element in the <see cref='DummyCollection'/>.
/// </summary>
public void Reset()
{
baseEnumerator.Reset();
}
}
}
}
on arrete pas de le dire : pas de ArrayList.
passer à 2005 et generics, ou generer ses classes en utilisant ce modele
en 2003 :
using System;
using System.Collections;
namespace Test
{
/// <summary>
/// A collection that stores <see cref='Dummy'/> objects.
/// </summary>
[Serializable()]
public class DummyCollection : CollectionBase {
/// <summary>
/// Initializes a new instance of <see cref='DummyCollection'/>.
/// </summary>
public DummyCollection()
{
}
/// <summary>
/// Initializes a new instance of <see cref='DummyCollection'/> based
another <see cref='DummyCollection'/>.
/// </summary>
/// <param name='val'>
/// A <see cref='DummyCollection'/> from which the contents are copied
/// </param>
public DummyCollection(DummyCollection val)
{
this.AddRange(val);
}
/// <summary>
/// Initializes a new instance of <see cref='DummyCollection'/>
containing any array of <see cref='Dummy'/> objects.
/// </summary>
/// <param name='val'>
/// A array of <see cref='Dummy'/> objects with which to intialize
the collection
/// </param>
public DummyCollection(Dummy[] val)
{
this.AddRange(val);
}
/// <summary>
/// Represents the entry at the specified index of the <see
cref='Dummy'/>.
/// </summary>
/// <param name='index'>The zero-based index of the entry to locate in
collection.</param>
/// <value>The entry at the specified index of the collection.</value>
/// <exception cref='ArgumentOutOfRangeException'><paramref
is outside the valid range of indexes for the collection.</exception>
public Dummy this[int index] {
get {
return ((Dummy)(List[index]));
}
set {
List[index] = value;
}
}
/// <summary>
/// Adds a <see cref='Dummy'/> with the specified value to the
/// <see cref='DummyCollection'/>.
/// </summary>
/// <param name='val'>The <see cref='Dummy'/> to add.</param>
/// <returns>The index at which the new element was inserted.</returns>
/// <seealso cref='DummyCollection.AddRange'/>
public int Add(Dummy val)
{
return List.Add(val);
}
/// <summary>
/// Copies the elements of an array to the end of the <see
cref='DummyCollection'/>.
/// </summary>
/// <param name='val'>
/// An array of type <see cref='Dummy'/> containing the objects to
to the collection.
/// </param>
/// <seealso cref='DummyCollection.Add'/>
public void AddRange(Dummy[] val)
{
for (int i = 0; i < val.Length; i++) {
this.Add(val[i]);
}
}
/// <summary>
/// Adds the contents of another <see cref='DummyCollection'/> to the
end of the collection.
/// </summary>
/// <param name='val'>
/// A <see cref='DummyCollection'/> containing the objects to add to
the collection.
/// </param>
/// <seealso cref='DummyCollection.Add'/>
public void AddRange(DummyCollection val)
{
for (int i = 0; i < val.Count; i++)
{
this.Add(val[i]);
}
}
/// <summary>
/// Gets a value indicating whether the
/// <see cref='DummyCollection'/> contains the specified <see
cref='Dummy'/>.
/// </summary>
/// <param name='val'>The <see cref='Dummy'/> to locate.</param>
/// <returns>
/// <see langword='true'/> if the <see cref='Dummy'/> is contained in
collection;
/// otherwise, <see langword='false'/>.
/// </returns>
/// <seealso cref='DummyCollection.IndexOf'/>
public bool Contains(Dummy val)
{
return List.Contains(val);
}
/// <summary>
/// Copies the <see cref='DummyCollection'/> values to a
<see cref='Array'/> instance at the
/// specified index.
/// </summary>
/// <param name='array'>The one-dimensional <see cref='Array'/> that is
the destination of the values copied from <see
cref='DummyCollection'/>.</param>
/// <param name='index'>The index in <paramref name='array'/> where
copying begins.</param>
/// <exception cref='ArgumentException'>
/// <para><paramref name='array'/> is multidimensional.</para>
/// <para>-or-</para>
/// <para>The number of elements in the <see cref='DummyCollection'/>
greater than
/// the available space between <paramref name='arrayIndex'/>
the end of
/// <paramref name='array'/>.</para>
/// </exception>
/// <exception cref='ArgumentNullException'><paramref name='array'/> is
<see langword='null'/>. </exception>
/// <exception cref='ArgumentOutOfRangeException'><paramref
name='arrayIndex'/> is less than <paramref name='array'/>'s lowbound.
</exception>
/// <seealso cref='Array'/>
public void CopyTo(Dummy[] array, int index)
{
List.CopyTo(array, index);
}
/// <summary>
/// Returns the index of a <see cref='Dummy'/> in
/// the <see cref='DummyCollection'/>.
/// </summary>
/// <param name='val'>The <see cref='Dummy'/> to locate.</param>
/// <returns>
/// The index of the <see cref='Dummy'/> of <paramref name='val'/> in
the
/// <see cref='DummyCollection'/>, if found; otherwise, -1.
/// </returns>
/// <seealso cref='DummyCollection.Contains'/>
public int IndexOf(Dummy val)
{
return List.IndexOf(val);
}
/// <summary>
/// Inserts a <see cref='Dummy'/> into the <see
at the specified index.
/// </summary>
/// <param name='index'>The zero-based index where <paramref
should be inserted.</param>
/// <param name='val'>The <see cref='Dummy'/> to insert.</param>
/// <seealso cref='DummyCollection.Add'/>
public void Insert(int index, Dummy val)
{
List.Insert(index, val);
}
/// <summary>
/// Returns an enumerator that can iterate through the <see
cref='DummyCollection'/>.
/// </summary>
/// <seealso cref='IEnumerator'/>
public new DummyEnumerator GetEnumerator()
{
return new DummyEnumerator(this);
}
/// <summary>
/// Removes a specific <see cref='Dummy'/> from the <see
cref='DummyCollection'/>.
/// </summary>
/// <param name='val'>The <see cref='Dummy'/> to remove from the <see
cref='DummyCollection'/>.</param>
/// <exception cref='ArgumentException'><paramref name='val'/> is not
found in the Collection.</exception>
public void Remove(Dummy val)
{
List.Remove(val);
}
/// <summary>
/// Enumerator that can iterate through a DummyCollection.
/// </summary>
/// <seealso cref='IEnumerator'/>
/// <seealso cref='DummyCollection'/>
/// <seealso cref='Dummy'/>
public class DummyEnumerator : IEnumerator
{
IEnumerator baseEnumerator;
IEnumerable temp;
/// <summary>
/// Initializes a new instance of <see cref='DummyEnumerator'/>.
/// </summary>
public DummyEnumerator(DummyCollection mappings)
{
this.temp = ((IEnumerable)(mappings));
this.baseEnumerator = temp.GetEnumerator();
}
/// <summary>
/// Gets the current <see cref='Dummy'/> in the <seealso
cref='DummyCollection'/>.
/// </summary>
public Dummy Current {
get {
return ((Dummy)(baseEnumerator.Current));
}
}
object IEnumerator.Current {
get {
return baseEnumerator.Current;
}
}
/// <summary>
/// Advances the enumerator to the next <see cref='Dummy'/> of the
cref='DummyCollection'/>.
/// </summary>
public bool MoveNext()
{
return baseEnumerator.MoveNext();
}
/// <summary>
/// Sets the enumerator to its initial position, which is before the
first element in the <see cref='DummyCollection'/>.
/// </summary>
public void Reset()
{
baseEnumerator.Reset();
}
}
}
}
on arrete pas de le dire : pas de ArrayList.
passer à 2005 et generics, ou generer ses classes en utilisant ce modele
en 2003 :
using System;
using System.Collections;
namespace Test
{
/// <summary>
/// A collection that stores <see cref='Dummy'/> objects.
/// </summary>
[Serializable()]
public class DummyCollection : CollectionBase {
/// <summary>
/// Initializes a new instance of <see cref='DummyCollection'/>.
/// </summary>
public DummyCollection()
{
}
/// <summary>
/// Initializes a new instance of <see cref='DummyCollection'/> based
another <see cref='DummyCollection'/>.
/// </summary>
/// <param name='val'>
/// A <see cref='DummyCollection'/> from which the contents are copied
/// </param>
public DummyCollection(DummyCollection val)
{
this.AddRange(val);
}
/// <summary>
/// Initializes a new instance of <see cref='DummyCollection'/>
containing any array of <see cref='Dummy'/> objects.
/// </summary>
/// <param name='val'>
/// A array of <see cref='Dummy'/> objects with which to intialize
the collection
/// </param>
public DummyCollection(Dummy[] val)
{
this.AddRange(val);
}
/// <summary>
/// Represents the entry at the specified index of the <see
cref='Dummy'/>.
/// </summary>
/// <param name='index'>The zero-based index of the entry to locate in
collection.</param>
/// <value>The entry at the specified index of the collection.</value>
/// <exception cref='ArgumentOutOfRangeException'><paramref
is outside the valid range of indexes for the collection.</exception>
public Dummy this[int index] {
get {
return ((Dummy)(List[index]));
}
set {
List[index] = value;
}
}
/// <summary>
/// Adds a <see cref='Dummy'/> with the specified value to the
/// <see cref='DummyCollection'/>.
/// </summary>
/// <param name='val'>The <see cref='Dummy'/> to add.</param>
/// <returns>The index at which the new element was inserted.</returns>
/// <seealso cref='DummyCollection.AddRange'/>
public int Add(Dummy val)
{
return List.Add(val);
}
/// <summary>
/// Copies the elements of an array to the end of the <see
cref='DummyCollection'/>.
/// </summary>
/// <param name='val'>
/// An array of type <see cref='Dummy'/> containing the objects to
to the collection.
/// </param>
/// <seealso cref='DummyCollection.Add'/>
public void AddRange(Dummy[] val)
{
for (int i = 0; i < val.Length; i++) {
this.Add(val[i]);
}
}
/// <summary>
/// Adds the contents of another <see cref='DummyCollection'/> to the
end of the collection.
/// </summary>
/// <param name='val'>
/// A <see cref='DummyCollection'/> containing the objects to add to
the collection.
/// </param>
/// <seealso cref='DummyCollection.Add'/>
public void AddRange(DummyCollection val)
{
for (int i = 0; i < val.Count; i++)
{
this.Add(val[i]);
}
}
/// <summary>
/// Gets a value indicating whether the
/// <see cref='DummyCollection'/> contains the specified <see
cref='Dummy'/>.
/// </summary>
/// <param name='val'>The <see cref='Dummy'/> to locate.</param>
/// <returns>
/// <see langword='true'/> if the <see cref='Dummy'/> is contained in
collection;
/// otherwise, <see langword='false'/>.
/// </returns>
/// <seealso cref='DummyCollection.IndexOf'/>
public bool Contains(Dummy val)
{
return List.Contains(val);
}
/// <summary>
/// Copies the <see cref='DummyCollection'/> values to a
<see cref='Array'/> instance at the
/// specified index.
/// </summary>
/// <param name='array'>The one-dimensional <see cref='Array'/> that is
the destination of the values copied from <see
cref='DummyCollection'/>.</param>
/// <param name='index'>The index in <paramref name='array'/> where
copying begins.</param>
/// <exception cref='ArgumentException'>
/// <para><paramref name='array'/> is multidimensional.</para>
/// <para>-or-</para>
/// <para>The number of elements in the <see cref='DummyCollection'/>
greater than
/// the available space between <paramref name='arrayIndex'/>
the end of
/// <paramref name='array'/>.</para>
/// </exception>
/// <exception cref='ArgumentNullException'><paramref name='array'/> is
<see langword='null'/>. </exception>
/// <exception cref='ArgumentOutOfRangeException'><paramref
name='arrayIndex'/> is less than <paramref name='array'/>'s lowbound.
</exception>
/// <seealso cref='Array'/>
public void CopyTo(Dummy[] array, int index)
{
List.CopyTo(array, index);
}
/// <summary>
/// Returns the index of a <see cref='Dummy'/> in
/// the <see cref='DummyCollection'/>.
/// </summary>
/// <param name='val'>The <see cref='Dummy'/> to locate.</param>
/// <returns>
/// The index of the <see cref='Dummy'/> of <paramref name='val'/> in
the
/// <see cref='DummyCollection'/>, if found; otherwise, -1.
/// </returns>
/// <seealso cref='DummyCollection.Contains'/>
public int IndexOf(Dummy val)
{
return List.IndexOf(val);
}
/// <summary>
/// Inserts a <see cref='Dummy'/> into the <see
at the specified index.
/// </summary>
/// <param name='index'>The zero-based index where <paramref
should be inserted.</param>
/// <param name='val'>The <see cref='Dummy'/> to insert.</param>
/// <seealso cref='DummyCollection.Add'/>
public void Insert(int index, Dummy val)
{
List.Insert(index, val);
}
/// <summary>
/// Returns an enumerator that can iterate through the <see
cref='DummyCollection'/>.
/// </summary>
/// <seealso cref='IEnumerator'/>
public new DummyEnumerator GetEnumerator()
{
return new DummyEnumerator(this);
}
/// <summary>
/// Removes a specific <see cref='Dummy'/> from the <see
cref='DummyCollection'/>.
/// </summary>
/// <param name='val'>The <see cref='Dummy'/> to remove from the <see
cref='DummyCollection'/>.</param>
/// <exception cref='ArgumentException'><paramref name='val'/> is not
found in the Collection.</exception>
public void Remove(Dummy val)
{
List.Remove(val);
}
/// <summary>
/// Enumerator that can iterate through a DummyCollection.
/// </summary>
/// <seealso cref='IEnumerator'/>
/// <seealso cref='DummyCollection'/>
/// <seealso cref='Dummy'/>
public class DummyEnumerator : IEnumerator
{
IEnumerator baseEnumerator;
IEnumerable temp;
/// <summary>
/// Initializes a new instance of <see cref='DummyEnumerator'/>.
/// </summary>
public DummyEnumerator(DummyCollection mappings)
{
this.temp = ((IEnumerable)(mappings));
this.baseEnumerator = temp.GetEnumerator();
}
/// <summary>
/// Gets the current <see cref='Dummy'/> in the <seealso
cref='DummyCollection'/>.
/// </summary>
public Dummy Current {
get {
return ((Dummy)(baseEnumerator.Current));
}
}
object IEnumerator.Current {
get {
return baseEnumerator.Current;
}
}
/// <summary>
/// Advances the enumerator to the next <see cref='Dummy'/> of the
cref='DummyCollection'/>.
/// </summary>
public bool MoveNext()
{
return baseEnumerator.MoveNext();
}
/// <summary>
/// Sets the enumerator to its initial position, which is before the
first element in the <see cref='DummyCollection'/>.
/// </summary>
public void Reset()
{
baseEnumerator.Reset();
}
}
}
}
> Ce que vous dites est vrai mais qui d'autre qu'un langage typé peut offrir
une liste universelle basée sur un ancètre commun à tous ? :-)
> Ce que vous dites est vrai mais qui d'autre qu'un langage typé peut offrir
une liste universelle basée sur un ancètre commun à tous ? :-)
> Ce que vous dites est vrai mais qui d'autre qu'un langage typé peut offrir
une liste universelle basée sur un ancètre commun à tous ? :-)
bjr,
y a t-il un moyen de specifier le type d'objet contenu dans un ArrayList
(ou un autre objet) ?
exemple:
public ArrayList toto()
{
ArrayList a = new ArrayList();
for(int i=0; i < 10;i++) a.Add(new String("toto"));
return a;
}
...
{
ArrayList a;
String b;
a = toto();
b=((Mot)a[0]).ToLower();
}
obligation de caster les objets utilisés, cela me semble moyen pour un
langage qui se veut typé.
merci
--
L'analphabète de l'an 2000 ne sera pas celui qui ne saura ni lire ni
écrire, mais celui qui ne saura apprendre, désapprendre et réapprendre -
Alvin Toffler
bjr,
y a t-il un moyen de specifier le type d'objet contenu dans un ArrayList
(ou un autre objet) ?
exemple:
public ArrayList toto()
{
ArrayList a = new ArrayList();
for(int i=0; i < 10;i++) a.Add(new String("toto"));
return a;
}
...
{
ArrayList a;
String b;
a = toto();
b=((Mot)a[0]).ToLower();
}
obligation de caster les objets utilisés, cela me semble moyen pour un
langage qui se veut typé.
merci
--
L'analphabète de l'an 2000 ne sera pas celui qui ne saura ni lire ni
écrire, mais celui qui ne saura apprendre, désapprendre et réapprendre -
Alvin Toffler
bjr,
y a t-il un moyen de specifier le type d'objet contenu dans un ArrayList
(ou un autre objet) ?
exemple:
public ArrayList toto()
{
ArrayList a = new ArrayList();
for(int i=0; i < 10;i++) a.Add(new String("toto"));
return a;
}
...
{
ArrayList a;
String b;
a = toto();
b=((Mot)a[0]).ToLower();
}
obligation de caster les objets utilisés, cela me semble moyen pour un
langage qui se veut typé.
merci
--
L'analphabète de l'an 2000 ne sera pas celui qui ne saura ni lire ni
écrire, mais celui qui ne saura apprendre, désapprendre et réapprendre -
Alvin Toffler
En plus de la notion de template et de classe dérivée mentionnées d ans les
réponses précédentes, vous pouvez également utiliser les fonction s
virtuelles, les « delegate » ainsi que la fonction .GetType(), sans c ompter
les mécanismes de « Reflexion », pour parfaire ce genre de code.
En plus de la notion de template et de classe dérivée mentionnées d ans les
réponses précédentes, vous pouvez également utiliser les fonction s
virtuelles, les « delegate » ainsi que la fonction .GetType(), sans c ompter
les mécanismes de « Reflexion », pour parfaire ce genre de code.
En plus de la notion de template et de classe dérivée mentionnées d ans les
réponses précédentes, vous pouvez également utiliser les fonction s
virtuelles, les « delegate » ainsi que la fonction .GetType(), sans c ompter
les mécanismes de « Reflexion », pour parfaire ce genre de code.
> J'ajouterais à ce sujet que c'est une façon de penser qui fonctionne bien
on n'a pas à ce soucier des performances.
Pour gagner en performance lors du runtime, il vaut mieux déléguer au
compilateur le plus de chose possible, comme la vérification des types.
Des boucles sur des centaines de lignes que l'on exécute souvent font
la différences entre les deux approches ;o)
> J'ajouterais à ce sujet que c'est une façon de penser qui fonctionne bien
on n'a pas à ce soucier des performances.
Pour gagner en performance lors du runtime, il vaut mieux déléguer au
compilateur le plus de chose possible, comme la vérification des types.
Des boucles sur des centaines de lignes que l'on exécute souvent font
la différences entre les deux approches ;o)
> J'ajouterais à ce sujet que c'est une façon de penser qui fonctionne bien
on n'a pas à ce soucier des performances.
Pour gagner en performance lors du runtime, il vaut mieux déléguer au
compilateur le plus de chose possible, comme la vérification des types.
Des boucles sur des centaines de lignes que l'on exécute souvent font
la différences entre les deux approches ;o)