[Message Deleted]
-
Comments:
shyamy wrote:
int Count=txtEnter.Text.Length,i=0;
Local variables are generally named with the first character in lower case, e.g.
count
instead ofCount
. There is no reason to initalise the variablei
, as you are not using it before you initialise it again in the loop.for(i=Count;i>0;i--)
Why are you looping from Count to 1 instead of from Count-1 to 0?
txtChange.Text+=myString.Substring(i-1,1);
Use a
StringBuilder
to build the string. That way you don't create so many string objects. Using the += operator to concatenate strings scales very badly; the execution time increases exponetially for each character you add. Instead of usingSubString
, use the indexer to get the character:myString[i-1]
, that way you use a char value to handle the character instead of creating another string object.--- b { font-weight: normal; }
-
private void btnChange_Click(object sender, System.EventArgs e) { //Variable which contains length (number of characters) of textbox txtEnter int Count=txtEnter.Text.Length; //Another variable which is called i and have 0 default value int i=0; //string variable which contains string of txtEnter control string myString=txtEnter.Text; //control loop which gives inverse word of myString variable //example: Hello for(i=Count;i>0;i--) { txtChange.Text+=myString.Substring(i-1,1); } } //result of txtChange TextBox control is olleH //Event which call Close() method private void btnExit_Click(object sender, System.EventArgs e) { this.Close(); }
Hope this helps
"My advice to you is to get married. If you find a good wife, you will be happy; if not, you will become a philosopher." Socrates