I'm currently reading a C# book, one of the examples has a code(added below) I'd like to run. Whilst I wrote it in visual studio 2005 and tried to compile I got an error "perhaps missing assembly". I read about assemblies, and found out how to add them but two questions-
a]how do I know which assembly I need?
b] I tried adding mscorlib and it says that it cann't be added and that it automatically referenced by the project system. heh??
my code is this, how can I make it work??
using System;
using System.Windows.Forms;
using System.Drawing;
public class frmapp : Form
{
private Label mydatelabel;
private Button btnupdate;
public frmapp()
{
initializecomponent();
}
private void initializecomponent()
{
this.text = environment.commandline;
this.startposition = formstartposition.centerscreen;
this.formborderstyle = formborderstyle.fixed3d;
mydatelabel = new label();
datetime currdate = new datetime();
currdate = datetime.now;
mydatelabel.text = currdate.tostring();
mydatelabel.autosize = true;
mydatelabel.location = new point(50, 20);
mydatelabel.backcolor = this.backcolor;
this.controls.add(mydatelabel);
this.width = (mydatelabel.prederredwidth + 100);
btnupdate = new button();
btnupdate.text = "update";
btnupdate.backcolor = color.lightgray;
btnupdate.location = new point(((this.width / 2) - (btnupdate.width / 2)), (this.height - 75));
this.controls.add(btnupdate);
btnupdate.click += new System.eventhandler(this.btnupdate_click);
btnupdate.mouseenter += new System.EventHandler(this.btnupdate_mouseenter);
btnupdate.mouseleave += new System.evenhandler(this.mydatalabel_mouseenter);
mydatelabel.mouseenter += new System.EventHandler(this.mydatalabel_mouseenter);
mydatelabel.mouseleave += new System.EventHandler(this.mydatalabel_mouseleave);
}
protected void btnupdate_click(object sender, System.EventArgs e)
{
datetime currdate = datetime.now;
this.mydatelabel.text = currdate.tostring();
}
protected void btnupdate_mouseenter(object sender, System.EventArgs e)
{
this.backcolor = color.hotpink;
}
protected void btnupdate_mouseleave(object sender, System.EventArgs e)
{
this.backcolor = color.blue;
}
protected void mydatalabel_mouseenter(object sender, System.EventArgs e)
{
this.backcolor = color.yellow;
}
protected void mydatalabel_mouseleave(object sender, System.EventArgs e)
{
this.backcolor = color.green;
}
public static void main(string[] args)
{
application.run(new frmapp());
}
}