Reverse string without using build in function

In this blog we will know how to reverse a string without using  build in function.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Reverse_string_without_built
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string str1 = textBox1.Text;
            string str2 = string.Empty;
            foreach(char chr in str1)
            {
                str2 = chr + str2;
            }
            MessageBox.Show(str2);
        } 
    }
}

Ebook Download
View all
Learn
View all