ویژگی های کمتر استفاده شده در NET. - بخش دوم
نویسنده: وحید محمدطاهری
تاریخ: ۱۳۹۶/۰۱/۰۴ ۱۴:۲۰
آدرس: www.dntips.ir
| مطالب | ۳۶۹۴ |
| نویسندگان | ۲۷۶ |
| گروههای مطالب | ۱۰۲۴ |
| نقشههای راه | ۱۱۹ |
| دورهها | ۱۴ |
| اشتراکها | ۱۷۹۱۴ |
public static class CurryMethodExtensions
{
public static Func< A, Func< B, Func< C, R > > > Curry< A, B, C, R >( this Func< A, B, C, R > f )
{
return a => b => c => f( a, b, c );
}
} Func< int, int, int, int > addNumbers = ( x, y, z ) => x + y + z; var f1 = addNumbers.Curry(); Func< int, Func< int, int > > f2 = f1( 3 ); Func< int, int > f3 = f2( 4 ); Console.WriteLine( f3( 5 ) );
public static class CurryMethodExtensions
{
public static Func< C, R > Partial< A, B, C, R >( this Func< A, B, C, R > f, A a, B b )
{
return c => f( a, b, c );
}
} Func< int, int, int, int > sumNumbers = ( x, y, z ) => x + y + z; Func< int, int > f4 = sumNumbers.Partial( 3, 4 ); Console.WriteLine( f4( 5 ) );
var obj = new WeakReferenceTest
{
FirstName = "Vahid"
};
var w = new WeakReference(obj);
obj = null;
GC.Collect();
var weakReferenceTest = w.Target as WeakReferenceTest;
if ( weakReferenceTest != null )
Console.WriteLine( weakReferenceTest.FirstName ); public abstract class ThreadSafeLazyBaseSingleton< T > where T : new()
{
static readonly Lazy< T > lazy = new Lazy< T >( () => new T() );
public static T Instance => lazy.Value;
} var positiveString = "91389681247993671255433422114345532000000"; var negativeString = "-9031583741089631207100208803453423537140000"; var posBigInt = BigInteger.Parse( positiveString ); Console.WriteLine( posBigInt ); var negBigInt = BigInteger.Parse( negativeString ); Console.WriteLine( negBigInt );