ATOUTFOX
COMMUNAUTÉ FRANCOPHONE DES PROFESSIONNELS FOXPRO
Visual FoxPro : le développement durable

Forum AtoutFox : Re: [C#] declaré un tableau (gregory)   

Sujet

rss Flux RSS des derniers messages

Vous devez vous identifier pour pouvoir poser une question ou répondre.

ven. 04 avril 2008, 10h13
Gregory
atoutfox.public.association

Re: [C#] declaré un tableau (gregory)

Olivier,

(1) [HS] Si tu ne connais pas la longueur d'un string d'avance - passe par
StringBuilder (regarde ma contrib)
(2) Dans le cas ci-dessous, pourquoi ne pas utiliser un ArrayList

static void doit()
{

var Olivier = new ArrayList();
Olivier.Add("David1");
Olivier.Add("David2");
Olivier.Add("David3");
Olivier.Add("David4");
Olivier.Add("David5");

Olivier.Add("Bobby");

for( int i=0; i < Olivier.Count; i++ )
Console.WriteLine(Olivier[i]);

// si les dim ne changent plus
String[] OlivierFinal =
(string[])Olivier.ToArray(typeof(string));
for (int i = 0; i < OlivierFinal.Length; i++)
Console.WriteLine(OlivierFinal[i]);
}
"OlivierH" <"nospam[contact]"@planitron.com> wrote in message
news:ft4mes$2hio$1@news.niouzes.net...
> Regarde cette inconvenient pour le redimensionnement des tableaux
>
> // 5 is the size of the array
> string[] names = new string[5];
> names[0] = "David";
> names[5] = "Bobby"; // Throws System.IndexOutOfRangeException
>
>
> // C# can't dynamically resize an array. Just copy into new array.
> string[] names2 = new string[7];
> Array.Copy(names, names2, names.Length); // or names.CopyTo(names2, 0);
>
> En fox on avait pas ce probleme, grrr !!
>
>
> Olivier QuiNeConnaitPasLeNombreDeLigneDeSonTableauAlavance
>
>
>
>
>
>
>
> Gregory a écrit :
>> Olivier,
>>
>> Correct - je ne connais pas les dimensions - sauf si je me mets a compter
>> les lignes qui suivent
>> Les lignes qui suivent initalisent le tableau
>>
>> static string[,] VatNumberFormat =
>> { { VATEXEMPT, null }, // Exempt
>> #if IN_BELGIUM
>> { " ","[01]\\d{9}" }, //
>> #endif
>> { "BE","[01]\\d{9}" }, // Belgium
>> { "AT","U\\d{8}" }, // Austria
>> { "BG","\\d{9,10}" }, // Bulgaria
>> ........
>>
>> { "SK","\\d{9,10}" } // Slovac Rep
>> };
>>
>> GregoryDimensioné
>> __
>> "OlivierH" <"nospam[contact]"@planitron.com> wrote in message
>> news:ft4inq$2g0o$2@news.niouzes.net...
>>> gregory,
>>>
>>> J'ai pas compris pourquoi tu as declaré le tableau de la facon suivante,
>>>
>>> static string[,] VatNumberFormat;
>>>
>>> Est ce parce que tu connais pas les dimensions ?
>>>
>>> Olivier
>>

--
Gregory
__
Permalink : http://www.atoutfox.org/nntp.asp?ID=0000002159
20 286 messages dans le forum • Liste complète des messages

www.atoutfox.org - Site de la Communauté Francophone des Professionnels FoxPro - v3.4.0 - © 2004-2026.
Cette page est générée par un composant COM+ développé en Visual FoxPro 9.0-SP2-HF3