Const | Read-Only |
---|---|
|
|
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
class constvalue
{
public const int conval = 10; //constant initialization
public readonly int tempvalue = conval; //read-only initialization
public constvalue(int rvalue)
{
tempvalue = tempvalue + rvalue; //read-only initialization in constructor
MessageBox.Show(tempvalue.ToString());
}
}
private void button1_Click(object sender, EventArgs e)
{
constvalue objconstvalue = new constvalue(100);
}
}
0 comments:
Post a Comment