Rewriting existing functionality in a .NET base class library

Regarding the other question I asked yesterday about logging, I met TraceListeners, whom I had never encountered before, and I'm very sorry. I can’t count the number of times I wrote to reporters unnecessarily to do this, and no one ever mentioned this or asked me why I didn’t use the built-in tools. This makes me wonder what other functions I forgot and wrote into my applications unnecessarily due to .NET features that I don't know about.

Does anyone else have .NET features that completely change the way they write applications or the components of their applications, did they know that .NET already has built-in support?

It would be convenient if other developers published scripts where they often came across components or blocks of code that are completely useless in retrospect, had an original developer known only from the built-in .NET component, such as TraceListeners, which I noted earlier.

This does not necessarily include the recently added 3.5 features as such, but may be, if this applies to the script.

Change . As in the previous comments, I am not interested in the “hidden features” of a language that I agree has been documented before - I look for often forgotten infrastructure components that, through my own (or original manifestation) ignorance, wrote / rewritten their own components / classes / methods unnecessarily.

+3
source share
4 answers

The yield keyword has changed the way code is written. This is an amazing little keyword that has tons of implications for writing really great code.

"differed invoke" , , - . , , .

FindAllData().Filter("keyword").Transform(MyTransform).ToList()

yield - , LINQ , , LINQ.

+5

, , - ASP.net. : http://aspnet.4guysfromrolla.com/articles/031407-1.aspx

, , - .

- . , MS , :)

+1

System.Net.WebClient . - , HttpWebRequest/HttpWebReponse. WebClient . , , WebClient ( cookie ).

-, , - String.Format(). , , "CompiledFormat", , . :

var PhoneFormat = new CompiledFormat("({0}){1}-{2}x{3}");
foreach (PhoneNumber item in MyPhoneList)
{
    Console.WriteLine(PhoneFormat.Apply(PhoneNumber.AreaCode, PhoneNumber.Prefix, PhoneNumber.Number, PhoneNumber.Extension));
}

Update:
This prompted me to finally do this. See Results here: Performance Error: Compared to String.Format

+1
source

Source: https://habr.com/ru/post/1706408/


All Articles