Eliminar espacios en blanco




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

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

//Variables
string textoentrada, textosalida = "", t;
int i, p;


// Entrada
private void textBox1_TextChanged(object sender, EventArgs e)
{
textoentrada = textBox1.Text;
}
//Proceso y salida
private void button1_Click(object sender, EventArgs e)
{
p = 0;
textoentrada = textoentrada.Trim();
for (i = 0; i < textoentrada.Length; i++)
{
if (textoentrada.Substring(i, 1).Equals(" "))
{
t = textoentrada.Substring(p, i - p);
p = i + 1;
textosalida = textosalida + t;
}
}
t = textoentrada.Substring(p, i - p);
textosalida = textosalida + t;


textBox2.Text = textosalida.ToString();
}




private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}

No hay comentarios:

Publicar un comentario

Nota: solo los miembros de este blog pueden publicar comentarios.