Advertisement
Guest User

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

a guest
Sep 6th, 2021
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.59 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3. using System.IO;
  4. using System.Windows.Forms;
  5.  
  6. namespace ConsoleRedirection
  7. {
  8.     public class TextBoxStreamWriter : TextWriter
  9.     {
  10.         TextBox _output = null;
  11.  
  12.         public TextBoxStreamWriter(TextBox output)
  13.         {
  14.             _output = output;
  15.         }
  16.  
  17.         public override void Write(char value)
  18.         {
  19.             base.Write(value);
  20.             _output.AppendText(value.ToString());
  21.  
  22.         }
  23.  
  24.         public override Encoding Encoding
  25.         {
  26.             get { return System.Text.Encoding.UTF8; }
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement