windows - C# Random method -
i developed 1 program, whats generates random numbers , letters , after write result xml file. there problem like, if press button generate once, doesn't anything, if press button second time in arrow generates.
private static void toxml(string xml_uri, string value) { xdocument doc; if (file.exists(xml_uri)) doc = xdocument.load(xml_uri); else doc = new xdocument(new xdeclaration("1.0", "utf-8", "yes"), new xelement("rndstr")); doc.element("rndstr").add(new xelement("str", value)); doc.save(xml_uri); } private void button1_click(object sender, eventargs e) { string file_name = "file.xml"; if (textbox1.text.length > 0) toxml(file_name, textbox1.text); textbox1.text = rndstr(10); }
if (textbox1.text.length > 0) toxml(file_name, textbox1.text); textbox1.text = rndstr(10); with current information gave. can on first clicking of button textbox1.text.length = 0 because setting text after executing check length , toxml method. put textbox1.text = rndstr(10); on if check , should happen on first click.
on second click value of text property set value of first click , because of working on second click. next time use debug lot in future. search articles in web debugging.
Comments
Post a Comment