byte表示(リフレクションメモ)

メモリチェック用

		private void button1_Click( object sender, EventArgs e ) {
			if ( textBox1.Text.Length == 0 ) {
				return;
			}
			try {
				if ( radioDouble.Checked ) {
					Show( typeof( double ) );
				} else if ( radioFloat.Checked ) {
					Show( typeof( float ) );
				} else if ( radioInt.Checked ) {
					Show( typeof( int ) );
				} else if ( radioLong.Checked ) {
					Show( typeof( long ) );
				} else if ( radioShort.Checked ) {
					Show( typeof( short ) );
				}
			} catch ( Exception ex ) {
				textBox2.Text = ex.Message;
			}
		}

		void Show(Type t) {
			var m =t.GetMethod( "Parse", new[]{typeof(string)} );
			var r = m.Invoke( null, new[] { textBox1.Text } ) ;
			var bytes = typeof( BitConverter ).GetMethod( "GetBytes", new[] { r.GetType() } ).Invoke( null, new[] { r } ) as byte[];

			if ( bytes != null ) {
				textBox2.Text = BitConverter.ToString( bytes ); 
			}
		}