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

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

        private void button1_Click(object sender, EventArgs e)
        {
            textBox1.Tag = "Ali";
            textBox2.Text = textBox1.GetTag();
            MessageBox.Show(textBox2.ToString(2));
            MessageBox.Show(button1.ToString(3));

        }
    }
    public static class My_Extensions
    {
        public static string GetTag(this Object  Obj)
        {
            return ((TextBox)Obj).Tag.ToString();
        }

        public static string ToString(this Object Obj, int x)
        {
            if (Obj is TextBox)
                return ((TextBox)Obj).Text.Substring(0, x);
            else
                if (Obj is Button)
                    return ((Button)Obj).Text.Substring(0, x);
                else return null ;
        }
    }

}
