Reverse string without built in function

Satyapriyanayak
Posted by Satyapriyanayak under C# category on | Points: 40 | Views : 1184
In this Code Snippet we will know how to reverse string without built 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);
}
}
}

Comments or Responses

Login to post response