Augmenter la capacité d'un list of string

Résolu
cs_ShayW Messages postés 3253 Date d'inscription jeudi 26 novembre 2009 Statut Membre Dernière intervention 3 décembre 2019 - Modifié le 4 mai 2017 à 16:39
Whismeril Messages postés 19024 Date d'inscription mardi 11 mars 2003 Statut Contributeur Dernière intervention 18 avril 2024 - 4 mai 2017 à 22:35
Bonjour

Selon le code suivant

Dim list1 As New List(Of String)

For k = 0 To Convert.ToInt64(2 ^ 26)
Try
list1.Add((k.ToString))
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Next

il y a une exception System.OutOfMemoryException

mais

 For k = 0 To Convert.ToInt64(2 ^ 26)

Try
list1.Add(("12345678906y86977"))

Catch ex As Exception
MessageBox.Show(ex.Message)
End Try

Next


pas d'exception

Merci

4 réponses

Whismeril Messages postés 19024 Date d'inscription mardi 11 mars 2003 Statut Contributeur Dernière intervention 18 avril 2024 656
4 mai 2017 à 17:29
Bonsoir

Donc ça n'est pas la liste.

Peux tu essayer
Dim list1 As New List(Of String)
   
     For k = 0 To Convert.ToInt64(2 ^ 26)
             Try
                 Dim toto as string = k.ToString()
                list1.Add(toto)
         Catch ex As Exception
                MessageBox.Show(ex.Message)
            End Try
    Next

0
cs_ShayW Messages postés 3253 Date d'inscription jeudi 26 novembre 2009 Statut Membre Dernière intervention 3 décembre 2019 57
4 mai 2017 à 17:52
Bonjour

j'obtiens la meme erreur
0
Whismeril Messages postés 19024 Date d'inscription mardi 11 mars 2003 Statut Contributeur Dernière intervention 18 avril 2024 656
Modifié le 4 mai 2017 à 18:22
et

Dim list1 As New List(Of String)
   
     For k = 0 To Convert.ToInt64(2 ^ 26)
             Try
                 Dim toto as string = k.ToString()
                list1.Add(toto)
                 toto = Nothing
         Catch ex As Exception
                MessageBox.Show(ex.Message)
            End Try
    Next 


Quand j'étais petit, la mer Morte n'était que malade.
George Burns
0
cs_ShayW Messages postés 3253 Date d'inscription jeudi 26 novembre 2009 Statut Membre Dernière intervention 3 décembre 2019 57
4 mai 2017 à 22:31
pareil

j'ai résolu en changant le target cpu à x64 ou anycpu
x86 cause un System.OutOfMemoryException
0
Whismeril Messages postés 19024 Date d'inscription mardi 11 mars 2003 Statut Contributeur Dernière intervention 18 avril 2024 656
4 mai 2017 à 22:35
0
Rejoignez-nous