문제 : 입력값을 배열로 받은 후 쉼표를 제거하고 배열을 역순으로 출력할 것[ Source Code ]using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Data;
namespace array1
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
/// Form 관련 디자인 소스는 생략하였음...너무 길어요...ㅡㅜ
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
/*
* 내가 만든 소스...
char[] split={','};
string[] inputArray;
inputArray = new string[100];
inputArray = textBox1.Text.Split(split,textBox1.Text.Length);
Array.Reverse(inputArray,0,inputArray.Length);
textBox2.Text = inputArray;
// 여기서 string[] 을 string 으로 잡아주면 출력 가능한데...ㅜㅜ
*/
// 도훈 군의 작품...
string[] inputArray = textBox1.Text.Split(',');
textBox2.Text = null;
foreach(object x in inputArray)
{
textBox2.Text = x + " " + textBox2.Text;
}
}
private void Form1_Load(object sender, System.EventArgs e)
{
}
}
}
댓글
댓글 쓰기