The lat part is not working why ????????
Please help.........
using System;
namespace ConsoleApplicat ion4
{
class reflection
{
public const string mstr = "hellpppo world!";
public System.Windows. Forms.TextBox textBox1;
[STAThread]
static void Main(string[] args)
{
this.textBox1 = new System.Windows. Forms.TextBox() ;
//
// textBox1
//
this.textBox1.B ackColor = System.Drawing. Color.FromArgb( ((System.Byte)( 128)), ((System.Byte)( 64)), ((System.Byte)( 0)));
this.textBox1.F ont = new System.Drawing. Font("Microsoft Sans Serif", 12F, System.Drawing. FontStyle.Regul ar, System.Drawing. GraphicsUnit.Po int, ((System.Byte)( 0)));
this.textBox1.F oreColor = System.Drawing. Color.FromArgb( ((System.Byte)( 192)), ((System.Byte)( 192)), ((System.Byte)( 0)));
this.textBox1.L ocation = new System.Drawing. Point(24, 48);
this.textBox1.N ame = "textBox1";
this.textBox1.T abIndex = 12;
this.textBox1.T ext = "textBox1";
this.Controls.A dd(this.textBox 1);
System.Reflecti on.FieldInfo fi =
Type.GetType("C onsoleApplicati on4.reflection" ) .GetField("mstr ");
string temp = (string)fi.GetV alue(null);
MessageBox.Show ("get string {0}", temp);
/////////// THIS IS NOT WORKING \\\\\\\\\\\
Type.GetType("C onsoleApplicati on4.reflection" ) .GetField("text box1");
string temp = (string)fi.GetV alue("Text");
MessageBox.Show ("get string {0}", temp);
\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\/////////////////////////////////
ERROR Object Type cannot be converted to target type
}
}
}
Please help.........
using System;
namespace ConsoleApplicat ion4
{
class reflection
{
public const string mstr = "hellpppo world!";
public System.Windows. Forms.TextBox textBox1;
[STAThread]
static void Main(string[] args)
{
this.textBox1 = new System.Windows. Forms.TextBox() ;
//
// textBox1
//
this.textBox1.B ackColor = System.Drawing. Color.FromArgb( ((System.Byte)( 128)), ((System.Byte)( 64)), ((System.Byte)( 0)));
this.textBox1.F ont = new System.Drawing. Font("Microsoft Sans Serif", 12F, System.Drawing. FontStyle.Regul ar, System.Drawing. GraphicsUnit.Po int, ((System.Byte)( 0)));
this.textBox1.F oreColor = System.Drawing. Color.FromArgb( ((System.Byte)( 192)), ((System.Byte)( 192)), ((System.Byte)( 0)));
this.textBox1.L ocation = new System.Drawing. Point(24, 48);
this.textBox1.N ame = "textBox1";
this.textBox1.T abIndex = 12;
this.textBox1.T ext = "textBox1";
this.Controls.A dd(this.textBox 1);
System.Reflecti on.FieldInfo fi =
Type.GetType("C onsoleApplicati on4.reflection" ) .GetField("mstr ");
string temp = (string)fi.GetV alue(null);
MessageBox.Show ("get string {0}", temp);
/////////// THIS IS NOT WORKING \\\\\\\\\\\
Type.GetType("C onsoleApplicati on4.reflection" ) .GetField("text box1");
string temp = (string)fi.GetV alue("Text");
MessageBox.Show ("get string {0}", temp);
\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\/////////////////////////////////
ERROR Object Type cannot be converted to target type
}
}
}
Comment