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, 11h29
OlivierH
atoutfox.public.association

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

Merci mon petit gregogorille,

c'est tres simple.

olivier,



Gregory a écrit :
> Mais, cela est facile. Tu dois declarer un string[] sans initialiser
>
> string[] TAB_INTERCAB ;
>
>
>
> static void doit()
> {
>
> // exemple 1: des \n
> string s = "line1\nligne2\nligne3\nligne4";
> string[] q;
>
> q = s.Split();
> for( int i = 0; i < q.Length; i++ )
> Console.WriteLine(q[i]);
>
> // exemple 2: des .
> s = "line1.ligne2.ligne3.ligne4";
> char[] splitChars = { '.' };
>
>
> q = s.Split(splitChars) ;
> for (int i = 0; i < q.Length; i++)
> Console.WriteLine(q[i]);
>
> // exemple 3: . et ,
> s = "line1.ligne2,ligne3.ligne4";
> char[] splitChars2 = { '.', ',' };
> q = s.Split(splitChars2) ;
> for (int i = 0; i < q.Length; i++)
> Console.WriteLine(q[i]);
> }
>
> }
> ___
>
> "OlivierH" <"nospam[contact]"@planitron.com> wrote in message
> news:ft4q57$2j13$2@news.niouzes.net...
>> ArrayList me plait bien mais je ne sais pas si cela va convenir
>>
>> Voila je récupère un champs meme d'une tableau que je converti en
>> tableau par .Split((char)13) (comme aline de VFP)
>>
>> Cette valeur j'aimerais la stocké dans un tableau .
>>
>> string[] TAB_INTERCAB = new string[1];
>>
>> TAB_INTERCAB =
>> DS.Tables["Agences"].Rows[0]["ag_secteur"].ToString().Trim().Split((char)13);
>>
>>
>> // bug car la dimension depasse l'indice declaré.
>>
>>
>> Olivier
>>
>>
>>
>>
>>
>> Gregory a écrit :
>>> 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
>>>>>
>>>
>
Permalink : http://www.atoutfox.org/nntp.asp?ID=0000002164
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