Adding an Obsolete Attribute to Class Methods in C#
As a developer we normally maintain our own framework, our own abstraction of things, be it database wrappers, our own implementations of persistence managers, in some cases we figure out a better way or new way of doing things so we decide to include it in the framework, how do we now tell other developers to use this instead of the old one?
The answer is the Obsolete Attribute.
We simply add this attribute on top of the method or class and specify our message. BTW, the Boolean parameter if set to True, will throw and exception if the class/method is used.
Happy Coding.
The answer is the Obsolete Attribute.
1 2 3 4 5 6 7 8 9 | [Obsolete("ExpandoObject.CreateObject is deprecated, please use NameValueCollection.CreateObject instead.", true)] public static void CreateObject(this ExpandoObject that, NameValueCollection querystring) { querystring.AllKeys.ToList().ForEach(x => { if (!that.ToDictionary(y => y.Key).ContainsKey(x)) ((IDictionary<string, object>)that)[x] = querystring[x]; }); } |
Happy Coding.
Comments