Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.46 KB | None | 0 0
  1. //C#
  2. // test2 du C# sur OpenSim
  3.  
  4.  
  5.  
  6. public void default_event_state_entry()
  7. {
  8.    
  9.    // tableau de int
  10.    int[] intT = new int[] { 1, 2, 3, 4, 5 };
  11.    
  12.    // test d'une boucle foreach
  13.    foreach( int i in intT )
  14.    {
  15.         llSay( 0, "Numero " + i );    
  16.    }
  17.    
  18.    // utilisation du Dictionary (inclus dans le framework)
  19.    System.Collections.Generic.Dictionary<int, string> dc = new System.Collections.Generic.Dictionary<int, string>();
  20.    
  21.    // on ajoute quelques données dans notre dictionary
  22.    dc.Add( 12, "hello" );
  23.    dc.Add( 1, "hi" );
  24.    dc.Add( 86, "o.o" );
  25.    dc.Add( 666, "@.@" );
  26.    
  27.    
  28.    // on affiche le contenu de dc avec un foreach
  29.    foreach( System.Collections.Generic.KeyValuePair<int, string> kvp in dc )
  30.       llSay( 0, "Key : " + kvp.Key + "; Value : " + kvp.Value );    
  31.    
  32.    // visiblement les expressions regulieres sont egalement supportées, pourquoi s'en priver o.o
  33.    System.Text.RegularExpressions.Regex rg = new System.Text.RegularExpressions.Regex( @"\w+" );
  34.    
  35.    // la chaine de caractères à tester avec notre regex
  36.    string toast = "expressions regulieres supportees ?";
  37.    
  38.    // on lance la recherche qu'on récupère dans une collection de Match
  39.    System.Text.RegularExpressions.MatchCollection mcs = rg.Matches( toast );
  40.    
  41.    // on affiche le résultat avec un foreach
  42.    foreach( System.Text.RegularExpressions.Match mc in mcs )
  43.         llSay( 0, "Found : " + mc.Groups[0].Value );
  44.    
  45.    
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement