Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
int s = 0;
for(int i=0;i<int.MaxValue;i++)
{
int i1 = i;
Expression<Func<int, int>> x = j => j + i1;
Func<int, int> f = x.Compile();
s += f(i);
if (i % 100 == 0)
{
Console.WriteLine(s);
GC.Collect();
}
}
Console.WriteLine(s);
Assembly [] b = AppDomain.CurrentDomain.GetAssemblies();
Console.WriteLine(«Before = » + b.Length);
int s = 0;
for (int i = 0; i < int.MaxValue; i++)
{
int i1 = i;
Expression<Func<int, int>> x = j => j + i1;
Func<int, int> f = x.Compile();
Assembly[] a = AppDomain.CurrentDomain.GetAssemblies();
Console.WriteLine(«After = » + a.Length);
s += f(i);
if (i % 100 == 0)
{
Console.WriteLine(s);
GC.Collect();
}
}
private static string GetMethodName<T>(Expression<Action<T>> action)
{
Expression body = action.Body;
var mce = body as MethodCallExpression;
if (mce != null)
return mce.Method.Name;
return null;
}
string beginMethodName = GetMethodName<Stream>(s => s.Read(null, 0, 0));
Expressions в C# — impress yourself!