Hi Friends.,
Here We Going to Reverse the Odd Number Strings and not the Even Strings (Even Strings) Will Display like As Entered.
In .aspx Page
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Convert.aspx.cs" Inherits="Convert" %>
In .aspx.cs Page
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class Convert : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public void btnConvert_Click(object sender, EventArgs e) //Button Click to Convert the Text.
{
string Text = tbxInputText.Text; // Assigning Text Box Value to String
int j = 0; // Declared Count of J = 0
string K = string.Empty; // Declared string K as Empty New string.
DataTable dt = new DataTable();
dt.Columns.Add("text"); //Creation of New DataTable to Bind the Splitted "string Text" Value in New Column "text".
for (int i = 0; i < Text.Length; i++) //Loop Created based on String Length it will Enter.
{
if (Text[i].ToString() == " ")
{
dt.Rows.Add(); //Adding New Rows in the DataTable.
dt.Rows[j][0] = K.ToString(); // Assigning K Value to Created DataTable.
j++; //To add Row
K = " "; // To Clear K Value for Further Use.
}
else if (i == Text.Length - 1) // To Bind the Last Value in the DataTable.
{
K = K + Text[i];
dt.Rows.Add(); //Adding New Rows in the DataTable.
dt.Rows[j][0] = K.ToString(); // Assigning K Value to Created DataTable.
j++; //To add Row
K = " "; // To Clear K Value for Further Use.
}
else // To Bind the Text Value to Form a Word.
{
K = K + Text[i];
}
}
string M = "";
string y = "";
for (int i = 0; i < dt.Rows.Count; i++) // Based on Count Loop Will Execute
{
if (i % 2 == 0) // if i Mod of 2 = 0 that Current Row Value in dt Will get Bind in M. It Will Bind Direct Values Which we give.
{
M = M + dt.Rows[i][0].ToString(); // Binding Direct Value here
}
else
{
string x = dt.Rows[i][0].ToString(); //It will Bind the Row Value in string x if i=1 it won't be Zero for i Mod 2 = 0 that kind of Value will get bind here
for (int z = x.Length - 1; z > 0; z--) // z-- will do count from greater to lesser for e.g : 6 to 1 it is used to bind Values in Reverese
{
y = y + x[z]; //Where y the Binded Value + x is Next Word [z] is Count.
}
M = M + " " + y; // Where M Already Bounded value + Space + Y Value (Reverese String)
y = ""; // to Clear Y Value to Use for Further.
}
}
tbxOutputText.Text = M.ToString(); // At the End M will get Whole Sentence as we need to Bind the M input to Textbox to Display.
}
}
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class Convert : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public void btnConvert_Click(object sender, EventArgs e) //Button Click to Convert the Text.
{
string Text = tbxInputText.Text; // Assigning Text Box Value to String
int j = 0; // Declared Count of J = 0
string K = string.Empty; // Declared string K as Empty New string.
DataTable dt = new DataTable();
dt.Columns.Add("text"); //Creation of New DataTable to Bind the Splitted "string Text" Value in New Column "text".
for (int i = 0; i < Text.Length; i++) //Loop Created based on String Length it will Enter.
{
if (Text[i].ToString() == " ")
{
dt.Rows.Add(); //Adding New Rows in the DataTable.
dt.Rows[j][0] = K.ToString(); // Assigning K Value to Created DataTable.
j++; //To add Row
K = " "; // To Clear K Value for Further Use.
}
else if (i == Text.Length - 1) // To Bind the Last Value in the DataTable.
{
K = K + Text[i];
dt.Rows.Add(); //Adding New Rows in the DataTable.
dt.Rows[j][0] = K.ToString(); // Assigning K Value to Created DataTable.
j++; //To add Row
K = " "; // To Clear K Value for Further Use.
}
else // To Bind the Text Value to Form a Word.
{
K = K + Text[i];
}
}
string M = "";
string y = "";
for (int i = 0; i < dt.Rows.Count; i++) // Based on Count Loop Will Execute
{
if (i % 2 == 0) // if i Mod of 2 = 0 that Current Row Value in dt Will get Bind in M. It Will Bind Direct Values Which we give.
{
M = M + dt.Rows[i][0].ToString(); // Binding Direct Value here
}
else
{
string x = dt.Rows[i][0].ToString(); //It will Bind the Row Value in string x if i=1 it won't be Zero for i Mod 2 = 0 that kind of Value will get bind here
for (int z = x.Length - 1; z > 0; z--) // z-- will do count from greater to lesser for e.g : 6 to 1 it is used to bind Values in Reverese
{
y = y + x[z]; //Where y the Binded Value + x is Next Word [z] is Count.
}
M = M + " " + y; // Where M Already Bounded value + Space + Y Value (Reverese String)
y = ""; // to Clear Y Value to Use for Further.
}
}
tbxOutputText.Text = M.ToString(); // At the End M will get Whole Sentence as we need to Bind the M input to Textbox to Display.
}
}

Upendra Pratap ShahiPosted Sep 30, 2015, 1:35 AM
Rajagopalan R VPosted Sep 30, 2015, 1:28 AM
Upendra Pratap ShahiPosted Aug 25, 2015, 7:45 AM
ValarmathiPosted Aug 25, 2015, 7:28 AM