http://csharp-video-tutorials.blogspo...
Slides
http://csharp-video-tutorials.blogspo...
Link for csharp, asp.net, ado.net, dotnet basics, mvc and sql server video tutorial playlists
https://www.youtube.com/user/kudvenka...
This is continuation to Part 78. Please watch Part 78, before proceeding.
One of the overloads of the Sort() method in List class expects Comparison delegate to be passed as an argument. Let us understand using this overloaded version.
public void Sort(Comparison[T] comparison)
Approach 1:
Step 1: Create a function whose signature matches the signature of System.Comparison delegate. This is the method where we need to write the logic to compare 2 customer objects.
private static int CompareCustomers(Customer c1, Customer c2)
{ return c1.ID.CompareTo(c2.ID);
}
Step 2: Create an instance of System.Comparison delegate, and then pass the name of the function created in Step1 as the argument. So, at this point "Comparison" delegate is pointing to our function that contains the logic to compare 2 customer objects.
Comparison[Customer] customerComparer = new Comparison[Customer](CompareCustomers);
Step 3: Pass the delegate instance as an argument, to Sort() function.
listCutomers.Sort(customerComparer);
At this point, listCutomers should be sorted using the logic defined in CompareCustomers() function.
Approach 2:
In Approcah1 this is what we have done
1. Created a private function that contains the logic to compare customers
2. Created an instance of Comparison delegate, and then passed the name of the private function to the delegate.
3. Finally passed the delegate instance to the Sort() method.
Do we really have to follow all these steps. Isn't there any other way? The above code can be simplified using delegate keyword as shown below.
listCutomers.Sort(delegate(Customer c1, Customer c2) { return (c1.ID.CompareTo(c2.ID)); });
Approach 3: The code in Approach 2, can be further simplified using lambda expression as shown below.
listCutomers.Sort((x, y) =] x.ID.CompareTo(y.ID));
Please make sure to replace [ with LESSTHAN and ] with GREATERTHAN symbol.
list of us presidents Part 79 Sort a list of complex types using Comparison delegate | |
247 Likes | 247 Dislikes |
67,886 views views | 524K followers |
Education | Upload TimePublished on 1 Sep 2013 |
Related keywords
generics pharmacy hiring,asp.net core docker,wcf vs web api,ado.net core,sql server management studio,webkinz,sorteio loteria federal,webadvisor,reverse grip bench press,sorteio da mega sena,craigslist nj,ascending psychology,wcf one piece,list of countries,asp.net core 3,ajax players,sorteador facebook,weber grill parts,webtoon,tutorials by hugo,csharp corner,mvc design pattern,asp.net machine account,servers for minecraft,asp.net core dependency injection,ado.net tutorial,generics menu card,services angular,listeria,ajax ontario,tutorial definition,tutorial on excel,asp.net mvc tutorial,reverse oyunu,sorteio facebook,reverse osmosis system,asp.net cos'è,reverse ne demek,csharp assembly,tutorialspoint python,sql join,services briefcase,asp.net core web api,ajax jquery,wccftech,craigslist ny,list of disney movies,asp.net zero,csharp foreach,server memes,sql date format,reverse grip pulldown,services online,reverse barbell curl,chase,serverless architecture,generics pharmacy logo,server resume,wcf c#,server books,tutorialspoint javascript,mvcc connect,ado.net mysql,services technologies gps,generics act of 1988,ajax deadpool,generics java,server jobs,sorteio mega sena hoje,cvs,website,mvc tutorial,sorteio copa do brasil,costco hours,wcf service application,ascendant sign,tutorialspoint spring,serverless,wcf soap,sorteio libertadores 2019,wcf cat,generics vs branded,wcf test client,cool math games,sorteio ao vivo,reverse ip,services & training hse colombia sas,servicestack,citibank,asp.net core identity,sql union,ajax parking,sql database,asp.net core logging,mvconnect,asp.net guida,cunyfirst,wcf nba,csharp download,reverse flash,wcfi foundation,reverse curl,csharp online,sorteador instagram,wcf authentication,sorteio tri legal,sorteio lotofacil,list of states,tutorials near me,http://asp.net,server 2019,ado.net descargar,web of dreams,chernobyl,serverminer,ajax cleaner,ascending and descending,ado.net visual studio 2019,tutorial for windows 10,sorteio no instagram,webassign,sorteio da quina de hoje,ado.net vs entity framework,ado.net visual studio 2017,csharp list,sql like,sorteiogram,asp.net mvc,asp.net core tutorial,reverse fly,sqlite,wcfm,reverse crunch,generics act,ajax roster,generics near me,tutorial gateway,reverse osmosis,mvc architecture,ascending colon pain,http://ado.net,list of marvel movies,asp.net core mvc,ajax soccer,server hosting,wcfi,list of us states,generics pharmacy cubao,generics pharmacy careers,ajax dish soap,sorteio,generics pharmacal phils. inc,capital one,listin diario,listings project,server rack,tutorialspoint html,csharp interface,craigslist,webroot,tutorialspoint reactjs,ajax request,wcf dragon ball,ascending colon function,generics c#,asp.net core 2.2,tutorialspoint python 3,sql developer,webster,generics pharmacy near me,services transmission company sas,ascending triangle,sql group by,asp.net core signalr,services manager,mvc framework,ajax paving,mvc near me,reverse engineering,reverse lunge,tutorialspoint spring boot,ascending cholangitis,mvc map,csharp online compiler,asp.net download,sql between,ado.net c# pdf,wcf 2019 nba,services tag dell,csharp switch,ado.net ventajas y desventajas,sorteio da quina,csharpstar,wcf tutorial,generics meaning,tutorialspoint,ascending loop of henle,ajax meaning,csharp-video-tutorials.blogspot,tutorials dojo,tutorial mission gta online,csharp string format,central park 5,ado.net c#,asp.net core github,ascending definition,server status,ajax fc,server jobs nyc,asp.net core swagger,sql formatter,credit karma,services group,server error in '/' application,ascending testicle,services windows,asp.net core 3.0,sql injection,wcf ria services,tutorialspoint c#,calculator,ado.net entity data model,sql insert,ascending aortic aneurysm,tutorialspoint tableau,ascending colon,services google play apk,ascending pharyngeal artery,sqlyog,ascending wedge,asp.net core 3 release date,sql server,server job description,tutorials by a,servicenow,webcam,mvc hours,webmd symptom,csharp array,sorteio tele sena,csharp enum,ascending aorta,ajax call,asp.net core 2. guida completa per lo sviluppatore,asp.net core,server pro,reverse image,server status ffxiv,webcrims,cheap flights,reverse grip lat pulldown,asp.net core hosting,services sas,ascending meaning,tutorialspoint java,listen to youtube,tutorialspoint java compiler,webmd,list of presidents,csharp to json,college football,ado.net dataset,csharp dictionary,tutorial meaning,cnn,website builder,tutorial.mc-complex,tutorialspoint sql,asp.net web api,server side rendering,weber grills,sorteie me,listerine,list of nba champions,sql server 2017,mvc nj,tutorialspoint spark,ado.net oracle,generics pharmacy pregnancy test reviews,asp.net core download,csharp to vb.net,listen linda,webster bank,list of sins,webstaurant,generics act of 1988 pdf,tutorial systems,tutorial teacher,tutorialsystems,ajax post,services fms publish announcement,services.msc no abre,list of vegetables,ajax jersey,csharp operator,asp.net core razor pages,server duties,asp.net core environment variables,tutorial on variational autoencoders,listen,csharp random,century 21,services consultores,services consulting,mvcsd,mvcsc,services.msc,ado.net pdf,asp.net core configuration,ajax marvel,tutorial synonym,sorteador de nomes,sql update,generics pharmacy head office,asp.net tutorial,mvc medical,generics awareness month,reverse card,ascending tracts,list comprehension python,generics king,ado.net entity data model visual studio 2019,wcfs international curriculum,mvc2,ado.net entity data model visual studio 2017,reverse image search,chase online,generics law,wcf api,costco,ascending pathways,server jobs near me,webex,sql meaning,sql tutorial,list of pokemon,ascending reticular activating system,sql commands,ado.net entity framework,ajax tavern,listen to your heart,tutorialsteacher,ajax javascript,services desk,ascending order,ajax greek,reverse triceps pushdown,csharp tutorial,mvc pattern,ado.net sql server,ado.net connection,asp.net identity,mvcu,asp.net core middleware,wcf web service,reverse pec deck,mvc webadvisor,tutorial music,web store,mvcc,sorte online,webmail,mvci,mvctc,
Không có nhận xét nào:
Đăng nhận xét