Development and Programming
C# and .NET
Marking a method as Obsolete/Deprecated in C#
The following C# code shows you how to use the Obsolete attribute to mark members and or types as obsolete. When a method has the Obsolete attribute, the C# compiler issues a warning if it is called. This helps keep programs correct. This makes it easier to transition from old methods.
[Obsolete("Use Dispose() instead")]
public void Close()
Adding a true value as second parameter, you can also cause the compilation to fail instead of warning if the method is called from somewhere in code.
[Obsolete("Use Dispose() instead"), true]
© 2017 Digcode.com. All rights reserved.