You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The let keyword is syntatic sugar, but it makes expressions a lot more readable (see LINQ documentation).
Here is an example from their documentation:
classLetSample1{staticvoidMain(){string[]strings={"A penny saved is a penny earned.","The early bird catches the worm.","The pen is mightier than the sword."};// Split the sentence into an array of words// and select those whose first letter is a vowel.varearlyBirdQuery=fromsentenceinstringsletwords=sentence.Split(' ')fromwordinwordsletw=word.ToLower()wherew[0]=='a'||w[0]=='e'||w[0]=='i'||w[0]=='o'||w[0]=='u'selectword;// Execute the query.foreach(varvinearlyBirdQuery){Console.WriteLine("\"{0}\" starts with a vowel",v);}// Keep the console window open in debug mode.Console.WriteLine("Press any key to exit.");Console.ReadKey();}}
We ran into this when translating the CMS Higgs stuff - and wanted to re-write the following C++ code into LINQ:
for (int i = 0; i < p.numberOfHits(); i++)
{
uint32_t hit = p.getHitPattern(i);
// if the hit is valid and in pixelif (p.validHitFilter(hit) && p.pixelHitFilter(hit)) {GM_PixelHits++;}
if (p.validHitFilter(hit)) {GM_ValidHits++;}
}
The text was updated successfully, but these errors were encountered:
The
let
keyword is syntatic sugar, but it makes expressions a lot more readable (see LINQ documentation).Here is an example from their documentation:
We ran into this when translating the CMS Higgs stuff - and wanted to re-write the following C++ code into LINQ:
The text was updated successfully, but these errors were encountered: