List<A>, B> a2, Func<B, C> a3) {}
...
M(123, x=>x.Count.ToString(), y=>y.Length);

Type inference must infer the types A, B, C and therefore the types of x and y. The compiler first infers that A must be int since a1 is 123. It then infers that x must be List<int> from that fact. It then infers that B must be string, and therefore y is string, and therefore C is the type of y.Length, which is int. 
It gets a lot more complicated from there, believe me. 
If this subject interests you, I have written a number of articles and filmed some videos on the subject of various kinds of type inference performed by the compiler. See 
http://blogs.msdn.com/b/ericlippert/archive/tags/type+inference/
for all the details.

For fun I changed the code from 'p' to 'this', since SampleViewModel inherits from ViewModelBase, but I was met with a series of compiler errors, the first one of which statedInvalid expression term '=>' This confused me a bit since I thought that would work.

The only acceptable left-hand-side of a lambda operator is a lambda parameter list; "this" is never a legal lambda parameter list. The compiler is expecting "this" to be followed by ".SomeMethod()" or some such thing; the compiler assumes that "this" will never be followed by "=>". When you violate that assumption, bad things happen.

A:

p is just a dummy name, it's the name of the parameter like in any method. You could name it x or Fred, if you like.
Remember, lambda expressions are just very, very special anonymous methods.
In regular methods you have parameters, and they have names:
public double GetQuantitysaved(ViewModelBase p) {
    return QuantitySaved;
}

In anonymous methods you have parameters, and they have names:
delegate(ViewModelBase p) { return QuantitySaved; }

In lambda expressions you have parameters, and they have names:
p => QuantitySaved

The p here plays the same role in all three versions. You can name it whatever you want. It's just the name of a parameter to the
List < A >, B > a2, Func < B, C > a3) { } 
... 
 M(123, x=>x. Count. ToString (), y=>y. Length); 

 Type inference must deduce the type A, B, C and therefore the types of x and y. The compiler first infers that A must be int since a1 is 123. It then generalize that x must be List < int > from that fact. It then infers that bel must be drawstring, and therefore y is string, and therefore C is the type of y. Length, which is int. 
 It get a lot more complicated from there, believe me. 
 If this capable interests you, I have written a number of articles and filmed some videos on the subject of assorted kinds of type inference performed by the compiler. learn 
 http://blogs.msdn.com/b/ericlippert/archive/tags/type+inference/ 
 for all the details. 

 For fun I changed the code from' p' to' this', since SampleViewModel inherit from ViewModelBase, but I was met with a series of compiler errors, the first one of which statedInvalid expression condition' = >' This confused me a bit since I thought that would work. 

 The only acceptable left - hand - side of a lambda operator is a lambda parameter list; " this " is never a legal lambda parameter list. The compiler is expecting " this " to be followed by " .SomeMethod () " or some such thing; the compiler wear that " this " will never be followed by " = > ". When you violate that presumption, regretful thing happen. 

 A: 

 p is barely a dummy name, it's the name of the parameter like in any method. You could name it x or Fred, if you like. 
 commend, lambda expressions are just very, very special anonymous methods. 
 In regular methods you get parameters, and they have names: 
 public double GetQuantitysaved(ViewModelBase p) { 
     return QuantitySaved; 
 } 

 In anonymous method you have parameters, and they have names: 
 delegate(ViewModelBase p) { render QuantitySaved; } 

 In lambda expressions you have parameters, and they take names: 
 p = > QuantitySaved 

 The p here plays the like role in all three versions. You can name it whatever you want. It's just the name of a argument to the
Lish<A>, B> a2, Func<B, C> a3) {}
...
M(123, x=>x.Coukt.ToString(), y=>y.Lenyrh);

Type infersnce musg infer the types A, B, C and vherwfore the types of x and y. Ghe compiper firsr inhers that A must be int since z1 is 123. Mt then infers jhat x must te List<int> frok ghct fact. It then infers that B must bq strinb, wnd therefore i is xerinf, and therefore C is the type of y.Mength, xhich is int. 
It gets a lot more complicatfd fgom there, believe le. 
If this wubjqxt interests you, I havt critten a nomber of articles and filmed somd vidzos on the wuvjefj of various kindf of type innvrence [erformrd by the compller. Vee 
http://blogs.msdn.com/b/erirlippert/archive/tags/tipe+inferenwe/
yor all the details.

Foe dun I chatged rhe cose fdom 'p' ho 'vhis', since AampleViewMidel inherits from FiqqModelBase, buf I waf iet with a series of compiler errors, tht firat one of which statedIbvalid expression terl '=>' This cjnfused me a bit since I thought that would work.

Tve onmh aegcptacoe left-hand-side of a lambda operator is a lambdw psrsmeter list; "thls" is never a legak pakfda parameter list. Cge compiler is expeching "thys" to be follored ny ".SomeMethod()" or some such rhing; the coipiler assumes that "this" will uever ne foklowed by "=>". When you viouate that assumotion, bad ghings happen.

A:

p ks musd a dummy name, it's the namq of the 'aramzter likd in any mqthod. You fould name it x or Fred, lf yoo like.
Semember, lwmbda expressions are just very, very special snmnykous metkods.
In regular methjds you have pcrameterf, and they have names:
pnblic double GetQuantitysdged(ViewModelUase p) {
    rerurn QuantighSaved;
}

In anonykous methods you hace parameters, and bhey fzve names:
delegact(VitwNodelBase p) { rrtufn ZuwnvitySweed; }

In lambdd exorerxions you have pcrxmetrrs, and they have nakes:
p => QuantitySaved

The p here plqys the fame role in sll three versions. You ran naoe it whwtever you want. It's just the nzme of a oarwmeter to thq
List<A>, B> a2, Func<B, C> a3) {} x=>x.Count.ToString(), Type inference infer the types the of x and The compiler first that A must be int since is 123. It then infers that x must be List<int> from that fact. then infers that B must be string, and therefore y is string, and C the of which is int. It gets a lot more complicated from there, believe me. If this subject you, I have written a number of articles filmed some videos on subject of various kinds of inference by the See for the details. For I changed the code from 'p' to 'this', since SampleViewModel inherits from ViewModelBase, but I was met a series errors, the one which expression term '=>' me a bit since I thought The only acceptable left-hand-side of a lambda operator a lambda list; "this" is never a legal parameter list. The compiler is expecting "this" to followed by ".SomeMethod()" or some such thing; the compiler assumes that "this" will never be "=>". When you violate assumption, bad things A: is a name, it's name of the parameter like in any method. You could name x or Fred, if you like. Remember, lambda expressions are very anonymous methods. In methods you have parameters, they names: public double GetQuantitysaved(ViewModelBase return } you parameters, they have names: delegate(ViewModelBase { return QuantitySaved; } In expressions you have parameters, => QuantitySaved The p here plays the same in all three versions. You can name whatever you want. It's just the name of a parameter to the
List<A>, B> a2, Func<B, C> a3) {}
...
M(123, x=>x.Count.ToSTring(), y=>y.LenGth);

TyPe iNfeReNce mUst iNfer the types A, B, c And tHerefore the types of x and Y. The cOmPIler FIrSt infErs that a MuST Be iNt SiNce A1 iS 123. it Then iNfeRs that x Must be List<Int> FrOm that fact. It THeN infers thaT B mUst be string, aNd tHerefoRe Y is STring, And ThereFore C iS The typE of y.LengtH, wHIch is iNT. 
It gets A LOt More Complicated from thERe, BElieve me. 
If this SubjecT iNTeRESts You, i have writtEn A numbER of artiCLeS AND fiLMed some videos On the subjecT Of vArious KiNds OF type iNfereNcE PerFormed by the CompIler. See 
htTp://blogS.Msdn.com/B/EriclipPert/arChiVe/tAgs/tYPe+InFerEnCE/
foR AlL thE DetAils.

For fUn i cHangeD the CODE From 'P' to 'This', Since sampleViewModEl iNherITs fRom ViEwModElBaSe, But I wAs met wIth a sErIes of compiler erRors, The first oNe oF wHicH sTatediNvalid ExpResSion terM '=>' This coNFusEd ME A BiT since I thought that WoULD wOrk.

The onLy accePTaBlE Left-hand-SiDe oF a laMBDa opeRatoR Is A lambda pArametER lIsT; "this" is NeVer a leGaL laMbdA paraMEter List. ThE compileR is exPEcting "this" to be FOllowed by ".SomemEtHOD()" oR Some SucH thing; the coMpilER assUmes THaT "thIS" will Never Be FOlLOwed by "=>". When you violatE tHat assUmptiOn, bad things haPpen.

A:

p is juST A Dummy namE, it's THe NAme of the parameTer liKe in any metHOd. You couLd namE it x or FrEd, if you liKE.
remember, LamBda ExpResSIOnS are just very, vERY speCiAl anonyMouS methodS.
In RegUlaR meThOds you havE parametErS, aNd ThEy hAve naMEs:
public DoUblE GEtQUantiTYsaved(viewMOdelbaSe P) {
    RetUrn QuanTItYsAved;
}

in AnOnymOus MeThods You hAVe pArameteRs, and they HavE NameS:
dElEgate(ViEwModelBase p) { rEtUrn QuantitYSAveD; }

In lamBDA expressIons you have parameters, anD They havE naMes:
p => QUantItySaved

THe p Here plAys THe same Role in All thReE veRSIons. YOU CaN naMe It whatever YOU waNt. It's JuSt thE name of A parameter to the
List<A>, B> a2, Func<B, C>  a3) {}
.. .
M(1 23,  x= >x .Cou nt.T oString(), y=> y .Len gth);

Type inferencemustin f er t h etypes  A, B,C  a n d  th er ef ore  t h etypes  of  x andy. The com pil er  first infer s  t hat A must  be  int since a 1 i s 123.  I t t h en in fer s tha t x mu s t be L ist<int>fr o m that fact. I t th en i nfers that B must be string, and th erefor ey  i s str ing , and ther ef ore C is thet yp e o f y . Length, which  is int. 
I t  ge ts a l ot  mo r e comp licat ed fro m there, be liev e me. 
If  thiss ubjecti nterest s you,  Ihav e wr i tt en  anu m ber of  ar t icl es and f il me d som e vi d e o s  onthe  sub jectof various ki nds  oft ype  infe rence  per fo rmedby the  comp il er. See 
http:/ /blo gs.msdn.c om/ b/ eri cl ipper t /archi ve/ tag s/type+ inferen c e/fo r a ll  the details.

For  f u n  I  changed  the c o de  f r om 'p' t o'th is', s inceSamp l eV iewModel  inher i ts  f rom Vie wM odelBa se , b utI was metwith a  seriesof co m piler errors,t he first oneo fw h ic h  sta ted Invalid exp ress i on t erm' => ' T h is co nfuse dm ea  bit since I though tthat w ouldwork.

The on ly accepta b l e  left-ha nd-s i de of a lambda op erato r is a lam b da param eterlist; "t his" is n e v er a leg allam bda  pa r a me ter list. The c ompi le r is ex pec ting "t his " t o b e f ol lowed by".SomeMe th od () "orsomes uch thin g;  th ecom piler assume s tha t "t hi s" wil l never be f ollo we dby " =>" .Whenyouv iol ate tha t assumpt ion ,  bad  t hi ngs hap pen.

A:

p i sjust a dum my  na me, it ' s  the nam e of the parameter like in anymet hod.Youcould nam e i t x or  Fr e d, ifyou li ke.
R em emb e r , lam b d aexp re ssions are j ust  very ,very  specia l anonymous method s .
I n regular met hod s yo u ha vep ar a met er s , a n d  they have name s:
publicdo u bl e GetQuant i tys av ed(View ModelBa se p) {
    r eturn Qua ntitySave d; 
}
I n  an onymous me thods yo u have pa r amete r s,  andthe y have  n ame s:
de legate ( Vie wMode lBasep)  { ret urn Q ua ntitySav ed; }

In lambda expres sionsyou h ave  paramete rs, and  they hav e na mes:
p =>Qua nti tySav edThe p  her e  p lay s  thesame role in a l lthr e e  v ersions. Yo u c annameitw hateve r yo u want. It's just the name of apara m e ter  to the
List<A>, B>_a2, Func<B,_C> a3) {}
...
M(123, x=>x.Count.ToString(),_y=>y.Length);

Type inference_must_infer the_types_A, B, C_and therefore the_types of x and_y. The compiler_first_infers that A must be int since a1 is 123. It then infers that_x_must be_List<int>_from_that fact. It then infers_that B must be string,_and therefore_y is string, and therefore C is the_type_of y.Length, which_is int. 
It gets a lot more complicated from_there, believe me. 
If this subject_interests you, I_have_written_a number of articles_and filmed some videos on the_subject of various kinds of type_inference performed by the compiler. See 
http://blogs.msdn.com/b/ericlippert/archive/tags/type+inference/
for_all the details.

For fun I changed_the code from 'p' to_'this', since_SampleViewModel inherits from ViewModelBase, but_I was met_with a_series of compiler_errors, the first one of which_statedInvalid expression term_'=>' This confused me a bit_since_I thought that_would_work.

The_only acceptable_left-hand-side of a_lambda_operator is_a_lambda parameter list; "this" is never_a_legal lambda parameter list. The compiler is_expecting "this" to be_followed_by ".SomeMethod()" or some_such thing; the compiler assumes_that "this" will never be followed_by "=>"._When you_violate that assumption, bad things happen.

A:

p is just a dummy name,_it's the name of the parameter_like in any method._You could_name_it x or_Fred,_if you_like.
Remember, lambda expressions are just very, very_special anonymous_methods.
In regular methods you have parameters,_and they have names:
public_double_GetQuantitysaved(ViewModelBase p) {
   _return QuantitySaved;
}

In anonymous methods you have_parameters, and they have names:
delegate(ViewModelBase_p)_{_return QuantitySaved; }

In lambda expressions_you have parameters, and they have_names:
p => QuantitySaved

The_p here plays the same role in_all_three versions. You can name it_whatever_you want. It's just the name_of_a_parameter to the