MethodA shows an Warning when called and MethodB is not an Obsolete Method
Users Online
· Guests Online: 101
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
Forum Threads
Newest Threads
No Threads created
Hottest Threads
No Threads created
Latest Articles
Articles Hierarchy
C# Program to Create Obsolete Class
C# Program to Create Obsolete Class
This is a C# Program to create obsolete class.
Problem Description
This C# Program Creates Obsolete Class.
Problem Solution
Here the Obsolete attribute generates a compile-time warning. When a method has the Obsolete attribute, the C# compiler issues a warning if it is called.
Program/Source Code
Here is source code of the C# Program to Create Obsolete Class. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.
/* * C# Program to Create Obsolete Class */ using System; class Program { static void Main() { MethodA(); MethodB(); Console.Read(); } [Obsolete("Use MethodB Instead")] static void MethodA() { } static void MethodB() { Console.WriteLine(" MethodA shows an Warning when called and "+ "MethodB is not an Obsolete Method "); } }
Program Explanation
In this C# program, we are creating two static methods methodA and methodB to use obsolete class. Hence the obsolete attribute generates a compile-time warning. When a method has the obsolete attribute, the C# compiler issues a warning if it is called.
Runtime Test Cases
Comments
No Comments have been Posted.
Post Comment
Please Login to Post a Comment.