小编sis*_*sve的帖子

如何将userInfo添加到UIAlertView?

我想知道如何将一个userInfo对象或任何NSDictionary添加到UIAlertView?

谢谢.

iphone objective-c nsdictionary uialertview userinfo

16
推荐指数
3
解决办法
8901
查看次数

物体复活的用法

我的.NET Windows服务应用程序中存在内存泄漏问题.所以我开始阅读有关.NET内存管理的文章.我在Jeffrey Richter的一篇文章中找到了一个有趣的练习.这个练习名称是"对象复活".它看起来像是将全局或静态变量初始化为"this"的位置代码:

protected override void Finalize() {
     Application.ObjHolder = this;
     GC.ReRegisterForFinalize(this);
}
Run Code Online (Sandbox Code Playgroud)

我知道这是一个不好的做法,但我想知道使用这种做法的模式.如果你知道,请写在这里.

c# clr memory-management

14
推荐指数
3
解决办法
4095
查看次数

C#函数重载规则

有关函数重载的规则是什么?

我有以下代码:

public T genericFunc<T>() where T : Component, new()
{
    T result = new T();
    overloadedFunction( result );
}

private overloadedFunction ( Component c ) // catch all function

private overloadedFunction ( DerivedFromComponent dfc) // specific function
Run Code Online (Sandbox Code Playgroud)

当我用以下代码调用上面的代码时:

genericFunc<DerivedFromComponent>();
Run Code Online (Sandbox Code Playgroud)

我希望调用更具体的overloadedFunction,但是会调用catch all函数,为什么会这样?单步执行上面的代码时,类型T确实是DerivedFromComponent,我认为CLR在运行时选择了最佳匹配!

c# clr overloading

9
推荐指数
1
解决办法
2614
查看次数

为什么这个代码不能在VS2010中用.NET 4.0编译?

不知何故,以下代码无法在VS2010中编译,而是在VS2012中编译而不进行更改.VS2010中有问题的一行是

names.Select(foo.GetName)
Run Code Online (Sandbox Code Playgroud)

错误CS1928:'string []'不包含'Select'的定义和最佳扩展方法重载'System.Linq.Enumerable.Select <TSource,TResult>(System.Collections.Generic.IEnumerable <TSource>,System. Func <TSource,TResult>)'有一些无效的参数.

using System;
using System.Linq;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main()
        {
            var foo = new Foo();
            var names = new[] {"Hello"};
            Console.WriteLine(string.Join(", ", names.Select(foo.GetName)));
        }
    }

    public class Foo
    {
    }

    static class Extensions
    {
        public static string GetName(this Foo foo, string name)
        {
            return name;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

.net c# linq visual-studio-2010 visual-studio-2012

9
推荐指数
1
解决办法
827
查看次数

布局扩展动画

我已经使用以下代码完成了布局展开动画.当我们通过单击文本视图调用动画时,它工作正常,但当我尝试通过单击布局来执行此操作时,不会发生相同的情况.任何人都可以帮我解决这个问题吗?

LinearLayout hello= (LinearLayout)findViewById(R.id.lin_hello);
final RelativeLayout rel=(RelativeLayout)findViewById(R.id.rel_nah_hide);
hello.setOnClickListener(new OnClickListener() {        
    @Override
    public void onClick(View v) {
        expand=!expand;
        Animation a=expand(rel, expand);
        rel.setAnimation(a);
        a.start();
    }
});

public static Animation expand(final View v, final boolean expand) {
    try {
        Method m = v.getClass().getDeclaredMethod("onMeasure", int.class, int.class);
        m.setAccessible(true);
        m.invoke(v,
                 MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
                 MeasureSpec.makeMeasureSpec(((View)v.getParent()).getMeasuredWidth(), MeasureSpec.AT_MOST)
        );
    } catch (Exception e) {
        e.printStackTrace();
    }

    final int initialHeight = v.getMeasuredHeight();

    if (expand) {
        v.getLayoutParams().height = 0;
    } else {
        v.getLayoutParams().height = initialHeight;
    }
    v.setVisibility(View.VISIBLE);

    Animation a = new Animation() …
Run Code Online (Sandbox Code Playgroud)

android android-animation android-layout

6
推荐指数
1
解决办法
4207
查看次数

CLR同步块地址

当我做:

public class Employee
{
    public int exp;
}

class Program
{
    static void Main(string[] args)
    {            
        Employee o1 = new Employee();
        o1.exp = 3;
        lock (o1)
        {
            //I am here
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

并获取o1的内存(地址为0x022cf940):

在此输入图像描述

我意识到下面提到的几件事情:

  1. 绿色矩形是同步块,即12
  2. 蓝色矩形是4字节类型的地址
  3. 红色矩形是4字节整数,即3;

问题:同步块的空间在哪里,我该如何找到它?"12"代表什么?

c# heap clr

6
推荐指数
1
解决办法
1164
查看次数

意外的系统.__佳能与反思

细分
"System.Reflection.TargetException:Object与目标类型不匹配." 在RealProxy的派生中调用MethodBase.Invoke时.在svn提交日志或服务器事件日志中突然出现问题并且没有任何明显的原因.

方案
Windows Server 2008 R2 Standard,64位
Microsoft .NET Framework版本:2.0.50727.4927
ASP.NET版本:2.0.50727.4927
IIS应用程序池以集成管道模式运行.
.NET Framework 4.0中是安装.

这些是一些压缩样本,以显示出现此问题的代码流.我已经删除了很多日志记录,合同等,只是为了保持这篇文章的代码简短.

// Interface structure
ICommentRepository : IRepository<Comment>  
IRepository<T> : IRepositoryWithTypedId<T, Guid>  
IRepositoryWithTypedId<T, TId>
    void Delete(T item);

// Extract from ServicesProvider which instantiates the proxies.
public class ServicesProvider {
    public T GetService<T>() where T : class {
        var proxy = WcfProxyFactory<T>.OpenChannel();
        proxy = ApplyLoggingProxy(proxy);
        return proxy;
    }

    private static T ApplyLoggingProxy<T>(T instance) where T : class {
        return (T)new LoggingProxy<T>(instance).GetTransparentProxy();
    }
} …
Run Code Online (Sandbox Code Playgroud)

.net c# clr

5
推荐指数
1
解决办法
2056
查看次数

在IE11中,站点无法正确显示

我有一个网站,可以在IE7,IE8,IE9,IE10,Firefox和Chrome,Opera和Safari的所有PC和Mac版本中正确显示.但是,在IE11中,它显示了部分标题和javascript,但没有显示html.有任何想法吗?

http://www.ighome.com

asp.net internet-explorer-11

4
推荐指数
1
解决办法
6389
查看次数