C# Interview Questions and Answers
<< Previous Question Next Question >>
 Question: 366 Page Views: 

What is Obsolete in C#? How can one make a method obsolete?



Posted By: Avi Date: 1 October 2010 11:32:31 AM
 Answer:

Obsolete attributemarks the program entity as the one that is not recommended to be used further. Using an entity markes as Obsolete will give generate an error or subsequent warning message. For example if a class in some program is to be obsoleted then it is done as follows:- [System.Obsolete("use class B")] class A { public void Method() { } } class B { [System.Obsolete("use NewMethod", true)] public void OldMethod() { } public void NewMethod() { } } In order to make a method as an obsolete try to write the following codes:- [Obsolete] public int printhello() {...} or [Obsolete(\"The method is obsolete\")] public int printhello() {...}


Posted By: avibtech


Date: 1 October 2010 11:32:31 AM
Post a better Answer if you have
 
(Will show your Gravatar icon)  
  Country flag

Loading
Enter the text as shown in the image QsYD31
Related Questions
C# : Write a code to reverse  List<int> data in C# using stack

Write a code to reverse List data in C# using stack

Stack<int> tmp = new Stack<int>(); int size = data.Count; for(int i = 0; i < size; i....
Category: C# Date: 10/14/2010 12:52:46 PM
C# : What is the meaning of the lock keyword?

What is the meaning of the lock keyword?

Lock marks a block of code as critical section by obtaining the mutual-exclusion lock for a given ob....
Category: C# Date: 10/14/2010 11:59:47 AM
C# : How do you use StreamWriter to write text to file?

How do you use StreamWriter to write text to file?

StreamWriter sw = new StreamWriter(filename); sw.WriteLine(“text”);sw.Close();
Category: C# Date: 10/14/2010 11:50:46 AM
C# : How do you use StringBuilder class?

How do you use StringBuilder class?

StringBuilder sb = new StringBuilder(); sb.Append(123).Append(“aaa”); sb.ToString();
Category: C# Date: 10/14/2010 11:38:31 AM
C# : Will this code Compie?
Public Interface ISomething { public void Sub();}