How to indicate that code is obsolete in C# .NET

Say you have a class or a class member that you’d like to remove at a later stage. You’ve probably seen compiler warnings or even errors with a message like “abc.efg is obsolete: ‘some message'”.

Let’s see quickly how to achieve it in C#.

The attribute to be aware of is Obsolete. It can decorate both classes, properties and methods. You can attach a useful message to it and make the compiler issue an error instead of the default warning. Let’s see an example:

[Obsolete]
public class CurrentCustomer
{
	public void Buy()
	{
	}
}

Read more of this post

Advertisements
ultimatemindsettoday

A great WordPress.com site

Elliot Balynn's Blog

A directory of wonderful thoughts

Softwarearchitektur in der Praxis

Wissenswertes zu Webentwicklung, Domain-Driven Design und Microservices

Technology Talks

on Microsoft technologies, Web, Android and others

Software Engineering

Web development

Disparate Opinions

Various tidbits

chsakell's Blog

WEB APPLICATION DEVELOPMENT TUTORIALS WITH OPEN-SOURCE PROJECTS

Guru N Guns's

OneSolution To dOTnET.

Johnny Zraiby

Measuring programming progress by lines of code is like measuring aircraft building progress by weight.

%d bloggers like this: