Advertisement
Guest User

[C#] Lấy Dữ Liệu Từ Console Write

a guest
Sep 6th, 2021
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using System.IO;
  9.  
  10. namespace ConsoleRedirection
  11. {
  12.     public partial class FormConsole : Form
  13.     {
  14.         TextWriter _writer = null;
  15.  
  16.         public FormConsole()
  17.         {
  18.             InitializeComponent();
  19.         }
  20.  
  21.         private void FormConsole_Load(object sender, EventArgs e)
  22.         {
  23.             _writer = new TextBoxStreamWriter(txtConsole);
  24.             Console.SetOut(_writer);
  25.  
  26.             Console.WriteLine("Now redirecting output to the text box");
  27.         }
  28.  
  29.         private void txtSayHello_Click(object sender, EventArgs e)
  30.         {
  31.             Console.WriteLine("Hello world");
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement