Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.
C# sealed variables
I want to declare a variable as a sealed and use that variable with in same class as we cannot use in other class.
class test
{
public sealed int x = 5;
public void abc()
{
MessageBox.Show(x.ToString());
}
}
class best :test
{
// public sealed int y = 10;// error..the modifer sealed is Not valid for this item
//private sealed int y = 10; // ""
//protected sealed int y = 10; // ""
public void print()
{
//MessageBox.Show(y.ToString()); // even when Iam commenting this line I am getting the same above error
//MessageBox.Show(x.ToString());
}
}
private void button1_Click(object sender, EventArgs e)
{
test t = new test();
t.abc();
best b = new best();
b.print();
}
Even Iam commenting the derived class also Iam getting the same error.
Error The modifier 'sealed' is not valid for this item
Profile Answers by aarruunnaa Questions by aarruunnaa
Questions by aarruunnaa answers by aarruunnaa
Related Answered Questions
Related Open Questions