Obsolete or Deprecated in NET Framework


The .NET Framework and its supporting languages changes over time. Each new version release, it adds new types and type members that provide new functionality and also existing types and their members also change over the time. Although Obsolete or Deprecated features remain in the current version, their use may throw warning messages recommending alternate practices, and deprecation warns that this feature will be removed in the future versions.


Applying this attribute to a type or member indicates that the type or member will be removed from the future version. The Obsolete attribute can be used without arguments, but including an explanation of why the item is obsolete and what to use instead is recommended.

C# Source Code

using System; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { OBClass a = new OBClass(); a.OBMethod(); } } [Obsolete("This class is obsolete; Use the new one instead")] class OBClass { public void OBMethod() { } } }

VB.Net Source Code

Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim ob As New OBClass ob.OBMethod() End Sub End Class <Obsolete("This class is obsolete; Use the new one instead")> _ Public Class OBClass Public Sub OBMethod() End Sub End Class