.


:




:

































 

 

 

 


, foreach . Count ().




, .

var posNums = from n in nums where n > 0 select n;

int len = posNums.Count(); //

Count () . .

, , Array () ToList (). Enumerable. ToAtray () , ToList () List. ( 25.) . , , posNums, .

int[] pnums = posNum.ToArray(); //

Foreach(int i in pnums)

Console.Write(i + " ");

}

, LINQ, , - . , -

, . System. Linq. Expressions. Expression<TDelegate>. , , SQL . , , . , , LINQ to SQL Visual Studio. , C# .

Compile (), Expression. , . Func System. Func , .

: -. -.

, . , , , . . , .

// .

Using System;

Using System.Linq;

Using System.Linq.Expressions;

class SimpleExpTree { static void Main() {

// - .

Expression<Func<int, int, bool

IsFactorExp = (n, d) => (d!= 0)? (n % d) ==0: false;

// .

Func<int, int, bool> IsFactor = IsFactorExp.Compile ();

// , if(IsFactor(10, 5))

Console.WriteLine(" 5 10.");

if(!IsFactor(10, 7))

Console.WriteLine(" 7 10.");

Console.WriteLine ();

}

}

.

5 10.

7 10.

. .

Expression<Func<int, int, bool

IsFactorExp = (n, d) => (d!= 0)? (n % d) ==0: false;

- . , , IsFactorExp. .

Func<int, int, bool> IsFactor = IsFactorExp.Compile();





:


: 2016-12-03; !; : 307 |


:

:

, .
==> ...

1549 - | 1389 -


© 2015-2024 lektsii.org - -

: 0.014 .