Aller au contenu | Aller au menu | Aller à la recherche

mardi, mai 2 2006

Enlever le dernier caractère d'une chaine :: c#

string ma_chaine="";
ma_chaine = ma_chaine.TrimEnd(';');

Spliter une chaine en c#

string chaine_a_spliter="1;2;3;6;fksdff;trztert;ertert"; string[] chaine= chaine_a_spliter.Split(new Char[] { ';' }); for (int x = 0; x < chaine.Length; x++) { Response.Write(chaine[x]); }

convertir une chaine string en INT :: c#

string mon_entier="11"; int mon_entier_converti=Convert.ToInt32(mon_entier); Response.Write (mon_entier_converti);

mardi, avril 18 2006

hashage MD5 d'une chaine en c#

public static string HashMD5(string Chaine) { return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(Chaine,"md5"); }

jeudi, mars 16 2006

Parcourir un flux XML

The namespace System.Xml would be the only additional namespace that we would be using.
Start of by initializing a new instance of the XmlDocument class.
XmlDocument xDoc = new XmlDocument(); Next use the load method to load the XML document from the specified stream.
xDoc.Load("sampleXML.xml"); Use the method GetElementsByTagName() to obtain the addresses of a collection
of elements that match the specified name.

XmlNodeList name = xDoc.GetElementsByTagName("myName");
XmlNodeList age = xDoc.GetElementsByTagName("myAge");
XmlNodeList represents an ordered collection of nodes.
Display the results in a message box.

MessageBox.Show("Name: " + name[0].InnerText)
InnerText will return the concatenated values of the node and all its children.
Et pour avoir la sous node: name[0].ChildNodes(0].InnerText

page 2 de 2 -