Emailid
Password
         
  
    Forgot password

New user Sign Up


Outmoded C# Code

       Current Rating:  70%                                                     Total Members Rated:  1
                                                                     Send To Friend

  

Outmoded C# Code

 

Introduction

 

New functionality will be added and existing classes, methods and properties will be improved when the class libraries evolve over time.  It means older code is superseded and it is preferable that it is marked as obsolete and it is not used ever.

 

Attribute Outmoded

 

A warning message can be provided to users of the class or member depending upon the usage of the attribute.  Outmoded attribute may be added to classes or class members to indicate that they have been superseded.  The message is displayed whenever a deprecated class is used or inherited from or when an out-of-date member is accessed. The message can be displayed as either a warning or as a compiler error when a user of the class library accesses the outdated definition. 

 

 Procedure

 

The simplest use of the obsolete attribute is with no parameters specified.  [Obsolete ()] is used to decorate the class or member being deprecated to apply the attribute.  On compilation of a program that uses the item, a warning that it is obsolete is issued.

 

[Obsolete()]

 

public class OutOfDateClass

 

{ ... }

 

 

Message of Caution

 

A message can be added as a string parameter of the attribute to improve the readability of a compiler warning.  This is displayed alongside the obsolete item warning when code that uses the class or member is compiled.

 

[Obsolete("This method has been superseded by the IsInUse() method")]

 

public void NotInUse()

 

{ ... }

 

Message of mistake

 

The attribute can be flagged with a Boolean that indicates that this is an error rather than a warning if using the deprecated version of the code is no longer supported at all or causes problems that are unacceptable.  Here, the code that uses a deprecated method cannot even be compiled.

 

[Obsolete("This method has been superseded by the IsInUse() method", true)]

 

public void NotInUse()

 

{ ... }

 

 

Wish you the best!

 


                           Rate This Article:   

Author is Offline
  Author: Mado Crazot
       


Comments Posted
Label
Subject Author Status Date

 

Post Comment

Related Articles
Fundamentals on .NET Framework
N-Tier in ASP.NET or other .NET apps
Software Development Outsourcing (Offshore ) to India
Make your web site ‘perfect and Search Engine Friendly for Google and Yahoo
Color combination of your Web site



Home | About Us | Site Map | Privacy Policy