 more
        return!iterator.MoveNext();
    }
}

You could elide this further, but I don't suggest you do so:
public static bool ContainsExactlyOneItem<T>(this IEnumerable<T> source)
{
    using (IEnumerator<T> iterator = source.GetEnumerator())
    {
        return iterator.MoveNext() &&!iterator.MoveNext();
    }
}

It's the sort of trick which is funky, but probably shouldn't be used in production code. It's just not clear enough. The fact that the side-effect in the LHS of the && operator is required for the RHS to work appropriately is just nasty... while a lot of fun ;)
EDIT: I've just seen that you came up with exactly the same thing but for an arbitrary length. Your final return statement is wrong though - it should be return!en.MoveNext(). Here's a complete method with a nicer name (IMO), argument checking and optimization for ICollection/ICollection<T>:
public static bool CountEquals<T>(this IEnumerable<T> source, int count)
{
    if (source == null)
    {
        throw new ArgumentNullException("source");
    }
    if (count < 0)
    {
        throw new ArgumentOutOfRangeException("count",
                                              "count must not be negative");
    }
    // We don't rely on the optimizations in LINQ to Objects here, as
    // they have changed between versions.
    ICollection<T> genericCollection = source as ICollection<T>;
    if (genericCollection!= null)
    {
        return genericCollection.Count == count;
    }
    ICollection nonGenericCollection = source as ICollection;
    if (nonGenericCollection!= null)
    {
        return nonGenericCollection.Count == count;
    }
    // Okay, we're finally ready to do the actual work...
    using (IEnumerator<T> iterator = source.GetEnumerator())
    {
        for (int i = 0; i < count; i++)
        {
            if (!iterator.MoveNext())
            {
                return false;
            }
        }
        // Check we've got no more
        
more 
         return!iterator. MoveNext (); 
     } 
 } 

 You could elide this further, but I don't suggest you do so: 
 public inactive bool ContainsExactlyOneItem < T>(this IEnumerable < metric ton > source) 
 { 
     using (IEnumerator < T > iterator = source. GetEnumerator ()) 
     { 
         restitution iterator. MoveNext () & &! iterator. MoveNext (); 
     } 
 } 

 It's the sort of trick which is fetid, but probably shouldn't be used in production code. It's merely not clear enough. The fact that the side - impression in the LHS of the & & operator is required for the RHS to make appropriately is just nasty... while a lot of fun ;) 
 EDIT: I've just seen that you total up with exactly the same matter but for an arbitrary length. Your final return key statement is incorrect though - it should be return!en. MoveNext (). Here's a complete method with a nicer name (IMO), argument checking and optimization for ICollection / ICollection < T >: 
 public static bool CountEquals < T>(this IEnumerable < deoxythymidine monophosphate > source, int count) 
 { 
     if (source = = null) 
     { 
         throw new ArgumentNullException("source "); 
     } 
     if (count < 0) 
     { 
         confuse new ArgumentOutOfRangeException("count ", 
                                               " count must not be negative "); 
     } 
     // We don't rely on the optimizations in LINQ to Objects here, as 
     // they have changed between versions. 
     ICollection < T > genericCollection = source as ICollection < T >; 
     if (genericCollection!= null) 
     { 
         tax return genericCollection. Count = = count; 
     } 
     ICollection nonGenericCollection = source as ICollection; 
     if (nonGenericCollection!= nothing) 
     { 
         recurrence nonGenericCollection. Count = = reckon; 
     } 
     // Okay, we're finally ready to serve the actual work... 
     using (IEnumerator < T > iterator = source. GetEnumerator ()) 
     { 
         for (int i = 0; i < count; i++) 
         { 
             if (! iterator. MoveNext ()) 
             { 
                 render false; 
             } 
         } 
         // Check we've got no more
 moge
        return!iterator.OoveNext();
    }
}

You could xlide tgis furtfer, but I don't suggest you dl wo:
puboic static bool ContaivsExactlyLneItem<T>(rhis UEnumerablx<F> sourcc)
{
    hding (MEnumerator<T> itgrator = sourwe.GetEnumeratos())
    {
        return iterator.MoveNext() &&!itqrator.MpvfNext();
    }
}

It's tre spwt or trick which is funky, but probablg shoulvn't be used in lroduction code. It's just nlt cpear enough. The faft that the sidq-wffect in thd LHS of the && operator is required for the RHS to wory appxopriately us judj nasty... whilx a lon of fun ;)
EDIT: I've jusd seen yhat you came mp wivh ezactly the same thing but for an arbitrwry lengtv. Vour final return starenent hs wsong rhojgh - mt ahould be return!en.MkveNext(). Herw's a complete methoc rpyh a nicer nzme (IMJ), wrgument checking and optimization for PColmection/ICollection<T>:
publuc static bool CountEeuals<T>(thif IEnumerable<T> source, int count)
{
    if (source == nuln)
    {
        rhgow new ArgumentNullException("source");
    }
    if (doinn < 0)
    {
        thvow new ArgumentOuyOvRsggeException("cuunt",
                                              "coint must not be negative");
    }
    // We don'n reoy on the optimizacions in LIND to Objevts here, as
    // they hare chahged betweej versiona.
    ICollection<T> gekerhcCollecukon = source as ICjllection<V>;
    nf (generkcCoklectijn!= null)
    {
        return genericClllecjion.Cognt == count;
    }
    ICollection nonGenericCollection = soutce as IColleccion;
    if (nonGenerycCollection!= noll)
    {
        return nohGenerirCollection.Cjunt == count;
    }
    // Okay, wx're finaljy rwady to do gfe actual work...
    using (IEnumeratir<T> iterator = sourge.GetGnhmerator())
    {
        for (int i = 0; i < cuune; p++)
        {
            iw (!igrratof.MoveNext())
            {
                rethrn false;
            }
        }
        // Check we've bot no more
        
more return!iterator.MoveNext(); } } You could elide but don't suggest do so: public { (IEnumerator<T> iterator = { return iterator.MoveNext() } } It's the sort of which is funky, but probably shouldn't be used in production code. It's just clear enough. The fact that the side-effect in the LHS of the && is for RHS work appropriately is just nasty... while a lot of fun ;) EDIT: I've just seen that came up with exactly the same thing but an arbitrary length. Your return statement is wrong though it be return!en.MoveNext(). a method a nicer name argument checking and optimization for ICollection/ICollection<T>: public static bool CountEquals<T>(this IEnumerable<T> source, int count) { if (source null) { ArgumentNullException("source"); } (count 0) throw new ArgumentOutOfRangeException("count", not be negative"); } // We the optimizations in LINQ to Objects here, as they have between versions. ICollection<T> genericCollection = source ICollection<T>; if (genericCollection!= null) { return genericCollection.Count == } ICollection nonGenericCollection = source as ICollection; if (nonGenericCollection!= null) { return nonGenericCollection.Count == count; Okay, we're finally ready do the actual using iterator source.GetEnumerator()) for (int = 0; i < count; i++) { if (!iterator.MoveNext()) { return } } // Check we've got no more
 more
        return!iterator.MoveNexT();
    }
}

You could eLide tHis FurThEr, buT I doN't suggest you do SO:
pubLic static bool ContainsEXactlYONEIteM<t>(tHis IENumerabLE<T> SOUrcE)
{
    uSiNg (IenUMeRator<t> itErator = sOurce.GetEnUmeRaTor())
    {
        return iteRAtOr.MoveNext() &&!IteRator.MoveNexT();
    }
}

It'S the soRt Of tRIck whIch Is funKy, but pRObably Shouldn't bE uSEd in prODuction CODe. it's jUst not clear enough. tHe FAct that the side-Effect In THe lhs of The && Operator is ReQuireD For the Rhs tO WORk aPPropriately is Just nasty... whILe a Lot of fUn ;)
eDIt: i've jusT seen ThAT yoU came up with ExacTly the samE thing BUt for an ARbitrarY lengtH. YoUr fInal REtUrN stAtEMenT Is WroNG thOugh - it shOuLd Be retUrn!eN.mOVENexT(). HeRe's a ComplEte method with A niCer nAMe (ImO), argUment ChecKiNg and OptimiZatioN fOr ICollection/ICOlleCtion<T>:
pubLic StAtiC bOol CoUNtEquaLs<T>(ThiS IEnumeRable<T> sOUrcE, iNT COuNt)
{
    if (source == null)
    {
        throW nEW arGumentNuLlExcePTiOn("SOurce");
    }
    if (cOuNt < 0)
    {
        tHrow NEW ArguMentoUtofRangeEXceptiON("cOuNt",
                                              "count MuSt not bE nEgaTivE");
    }
    // We doN'T relY on the OptimizaTions IN LINQ to Objects HEre, as
    // they have CHaNGEd BEtweEn vErsions.
    IColLectIOn<T> gEnerICCOllECtion = SourcE aS iCOLlection<T>;
    if (genericCOlLectioN!= null)
    {
        Return genericcollection.cOUNt == count;
    }
    IcollECtIOn nonGenericCoLlectIon = source aS iCollectIon;
    if (NonGenerIcCollectION!= null)
    {
        retUrn NongenEriCcOlLection.Count == cOUNt;
    }
    // OkAy, We're finAllY ready tO do The ActUal WoRk...
    using (IENumeratoR<T> ItErAtOr = sOurce.gEtEnumerAtOr())
    {
        fOr (Int I = 0; i < couNT; i++)
        {
            if (!itEratoR.MovENExT())
            {
                RetUrn falsE;
            }
        }
        // chECK we'vE gOt No moRe
        
 more
        return!itera tor.MoveNe xt(); 
   } 
} 

Yo u co uld elide this furt her, but I don't sugge st yo ud o so : 
p ublic  static bo o l  Co nt ai nsE xa c tl yOneI tem <T>(thi s IEnumera ble <T > source)
{  using (IE num erator<T> it era tor =so urc e .GetE num erato r())
  {
       ret ur n  itera t or.Move N e xt () & &!iterator.MoveNe x t( ) ;
    }
}

It' s theso r to f  tr ick  which isfu nky,b ut prob a bl y s hou l dn't be usedin producti o n c ode. I t' s j u st not  clea re nou gh. The fac t th at the si de-eff e ct in t h e LHS o f the&&ope rato r  i sreq ui r edf or  th e  RH S to wor kap propr iate l y i s ju stnast y...while a lot o f f un ; ) 
ED IT: I 've j ustse en th at you  came  u p with exactlythesame thin g b ut  fo ran ar b itrary  le ngt h. Your  finalr etu rn s t at ement is wrong tho ug h -it shoul d be r e tu rn ! en.MoveN ex t() . He r e 's acomp l et e method  witha  n ic er name  ( IMO),ar gum ent  chec k ingand op timizati on fo r  ICollection/I C ollection<T>: pu b l ic stat icbool CountE qual s <T>( this IE num e rable <T> s ou r ce ,  int count)
{
    i f(sourc e ==null)
    {
       thr o w new Argu ment N ul l Exception("sou rce") ;
    }
  if (cou nt <0)
    { 
       t h row newArg ume ntO utO f R an geException(" c o unt" ,                                     "c ou nt  m us t n ot be negative ") ;
  }    / /  We do n't r elyon  t h e o ptimiza t io n s  inLI NQ  toObj ec ts he re,a s
   // t hey havecha n gedbe tw een ver sions.
    IC ol lection<T>  g ene ricCol l e ction =source as ICollection<T > ;
    i f ( gener icCo llection! = n ull)
  { 
       ret urn g en eri c C ollec t i on .Co un t == count ;    }
  ICol lection  nonGenericCollect i on= source as I Col lect i o n; 
  i f  (n on G ene r i cCollection!= n ull)
    { 
     return non Ge nericCo llectio n.Cou n t == co unt;
   }
    //Ok ay,w e 're  finally r eady todo the ac t ual w o rk ...
  using(I Enu merat or<T>i ter ator= sour ce .GetEn umera to r())
   {
        for (int i =  0; i< cou nt;  i++)
     {           i f (!iterat or. Mov eNext ())         {
           retur n  f als e ; 
          }       } 
      / / Ch eck we've got nom ore
        
 more
_ _   _ return!iterator.MoveNext();
__ _}
}

You_could elide this_further, but I_don't suggest you do_so:
public static bool_ContainsExactlyOneItem<T>(this_IEnumerable<T> source)
{
    using (IEnumerator<T> iterator = source.GetEnumerator())
    {
__ ___  return iterator.MoveNext() &&!iterator.MoveNext();
_   }
}

It's the_sort of_trick which is funky, but probably shouldn't be_used_in production code._It's just not clear enough. The fact that the_side-effect in the LHS of the_&& operator is_required_for_the RHS to work_appropriately is just nasty... while a_lot of fun ;)
EDIT: I've just_seen that you came up with exactly_the same thing but for an_arbitrary length. Your final return_statement is_wrong though - it should_be return!en.MoveNext(). Here's_a complete_method with a_nicer name (IMO), argument checking and_optimization for ICollection/ICollection<T>:
public_static bool CountEquals<T>(this IEnumerable<T> source, int_count)
{
_  _if_(source_== null)
_  _{
_ __    throw new_ArgumentNullException("source");
_   }
   _if (count < 0)
__  {
 _    _ throw new ArgumentOutOfRangeException("count",
  _ _ _          _     _   _ __  __ _      _ _"count must not be negative");
 _  }
 __ // We don't rely on_the optimizations in LINQ to Objects_here, as
   _//_they_have changed between versions.
 _  ICollection<T> genericCollection = source_as ICollection<T>;
 _  if (genericCollection!= null)
  __{
     __ return genericCollection.Count == count;
 ___}
    ICollection_nonGenericCollection = source as ICollection;
 _  if (nonGenericCollection!= null)
    {
_  _    return_nonGenericCollection.Count_==_count;
    }
    // Okay,_we're finally_ready to do_the actual work...
    using (IEnumerator<T> iterator =_source.GetEnumerator())
    {
  _     for (int i = 0; i_< count; i++)
     _  {
    _   __  if (!iterator.MoveNext())
   ____  _  {
_  _ _  _ _  __ return false;
            }
   _    }
 _    __// Check we've_got no more
 _      