forked from ahotko/c-sharp-code-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ObsoleteSample.cs
33 lines (30 loc) · 1.11 KB
/
ObsoleteSample.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
namespace CodeSamples.Attributes
{
sealed class ObsoleteExamples
{
//with "false" as the last parameter, compiler warning will be generated, if property is used anywhere
[Obsolete("This property is obsolete.", false)]
public string OldStringValue { get; set; }
//with "true" as the last parameter, compiler error will be generated, if method is called anywhere
[Obsolete("This method is obsolete.", true)]
public int OldGetIntValue()
{
return 5 * 2;
}
}
public class ObsoleteSample : SampleExecute
{
public override void Execute()
{
Title("ObsoleteSampleExecute");
Section("Creating class (messages only at compile time)");
ObsoleteExamples obsoleteExample = new ObsoleteExamples();
//following line produces compiler warning
obsoleteExample.OldStringValue = String.Empty;
//following line produces compiler error, if uncommented
//int value = obsoleteExample.OldGetIntValue();
Finish();
}
}
}