问题列表 - 第38142页

具有公共字段的不同类之间的IEnumerable.Except()

是否可以使用Except()两个具有两个不同类但是共同字段的Lis​​t?我有List<User1>List<User2>收藏品.它们具有除Id列以外的不同属性,我想使用此Id列找到它们之间的不同记录.我正在尝试使用,List<>.Except()但我收到此错误:

无法从用法推断出方法'System.Linq.Enumerable.Except(System.Collections.Generic.IEnumerable,System.Collections.Generic.IEnumerable)'的类型参数.尝试显式指定类型参数.

这是我正在尝试的:

List<User1> list1 = List1();
List<User2> list2 = List2();
var listdiff = list1.Except(list2.Select(row => row.Id));
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

c# linq ienumerable .net-3.5

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

通用字典,其值为具有通用引用的接口

我想要一个字典,其中值是通用对象,并且对于字典中的每个值都不相同.怎么能这样做,我觉得我错过了一些简单的事情.

例如


    public interface IMyMainInterface
    {
        Dictionary<string, IMyInterface<T>> Parameters { get; }
    }

    public interface IMyInterface<T>
    {
        T Value
        {
            get;
            set;
        }

        void SomeFunction();
    }

Result:
dic.Add("key1", new MyVal<string>());
dic.Add("key2", new MyVal<int>());

Run Code Online (Sandbox Code Playgroud)

.net c# generics

3
推荐指数
1
解决办法
7466
查看次数

更改Android Project SDK级别

在开始使用Android手机之前,我开始编写我的第一个Android应用程序,并选择了SDK 2.0.1.我想在Android 1.6的手机上测试应用程序.应用程序本身使用非常简单的东西,所以我确信它的1.6兼容,但我想从Eclipse更改SDK级别.

我的项目树中的"default.properties"文件天真地尝试从Android 6更改,但它不可更改,但如果我尝试更改它,它会告诉我更改项目的build.properties.我不知道这意味着什么.我不习惯日食,而且还在摸索它.

我转到项目属性并单击"Java Build Path",但从那里我不知道如何添加,删除或编辑库.

基本上,我问的是如何从Eclipse中降级我的项目,所以我可以将它导出到兼容的手机.

eclipse sdk android downgrade

8
推荐指数
1
解决办法
2万
查看次数

如何在CSS规则中显示有display:none的元素?

我有一个非常简单的外部css样式表,它具有以下内容:

div.hideBox {
    display:none;
}
Run Code Online (Sandbox Code Playgroud)

因此,当加载html页面时,具有该类属性"hideBox"的div将不会显示在页面上,这就是我想要的.但是当用户点击同一页面上的按钮时,我会显示/显示该框.我尝试使用onclick事件来执行此操作,但div不会显示.

例如,代码将是:

<script language="javascript">
function showmydiv() {
document.getElementById('mybox').style.display = "";
}

</script>
</head>
<body>
<div id="mybox" class="hideBox">
some output of text
</div>
<input type="button" name="ShowBox" value="Show Box" onclick="showmydiv()">
Run Code Online (Sandbox Code Playgroud)

奇怪的是,当我使用时,类似于此的设置可以工作visibility:hidden; position:absolute;,我可以使用JavaScript函数来显示<div>.

我在这做错了什么?

html javascript css

46
推荐指数
3
解决办法
19万
查看次数

将mysql表从latin1转换为utf8

我正在尝试将一些mysql表从latin1转换为utf8.我正在使用以下命令,这似乎主要起作用.

ALTER TABLE tablename CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
Run Code Online (Sandbox Code Playgroud)

但是,在一个表上,我收到有关重复键输入的错误.这是由"名称"字段上的唯一索引引起的.在转换为utf8时,似乎任何"特殊"字符都被索引为它们的直接英语等价物.例如,已存在名称字段值为"Dru"的记录.转换为utf8时,带有"Drü"的记录被视为重复记录.与"Patrick"和"Påtrìçk"相同.

以下是如何重现该问题:

CREATE TABLE `example` (   `name` char(20) CHARACTER SET latin1 NOT NULL,
  PRIMARY KEY (`name`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;

INSERT INTO example (name) VALUES ('Drü'),('Dru'),('Patrick'),('Påtrìçk');

ALTER TABLE example convert to character set utf8 collate utf8_general_ci;
ERROR 1062 (23000): Duplicate entry 'Dru' for key 1
Run Code Online (Sandbox Code Playgroud)

mysql collation utf-8 latin1 mysql-error-1062

16
推荐指数
1
解决办法
1万
查看次数

编码URL导致来自浏览器的禁止消息的奇怪问题

准备好一些陌生感.以下在Fi​​refox中运行良好:

重定向到此网址:

http://localhost/webs/van/front-end/slr/edit_rule.php?rule_name=test&rule_type=alloc_ext&copy=1
Run Code Online (Sandbox Code Playgroud)

但是,它在IE8中不起作用,因为它将上面的内容转换为此,请注意最后地址中的版权符号:

http://localhost/webs/van/front-end/slr/edit_rule.php?rule_name=test&rule_type=alloc_ext©=1
Run Code Online (Sandbox Code Playgroud)

所以,我觉得很奇怪,就encodeURIComponent这样:

window.location.href = 'edit_rule.php%3Frule_name%3Dtest%26rule_type%3Dalloc_ext%26copy%3D1';
Run Code Online (Sandbox Code Playgroud)

同时,Firefox和IE8现在给我一个禁止的消息!?!

您无权访问/webs/van/front-end/slr/edit_rule.php?此服务器上的rule_name = test2&rule_type = alloc_ext© = 1.

我不明白,发生了什么事?

谢谢大家的帮助.

javascript php internet-explorer

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

使用任务管理器生成转储文件

我知道使用Vista,您可以通过goigg生成转储文件到任务管理器 - >进程 - >右键单击该进程.

这个选项在其他版本的Windows中是否可用,这意味着Windows 7,Windows 2003,Windows 2008等?

windows

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

在 WPF 中的虚拟化列表框上正确设置宽度

我有一个 WPF 列表框,它被大量行虚拟化。当我滚动浏览实体时,列表框的大小会发生变化。我试过了:

<Setter Property="MinWidth" Value="{Binding Path=ExtentWidth, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ScrollViewer}}}" />
Run Code Online (Sandbox Code Playgroud)

遗憾的是,我没有足够的声誉来发布我的问题图片,但基本上当我滚动虚拟化列表框时,框的宽度会随着遇到更长的项目而变化。我想我可以尝试测量代码隐藏中最长的字符串并将宽度设置为该值,但我希望有一个更清晰的解决方案。

这是我当前的控制模板(没有骰子):

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                    <Border x:Name="ListItemContainer"
                             MinWidth="{Binding Path=ExtentWidth, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ScrollViewer}}}"
                            BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
                        <ContentPresenter></ContentPresenter>                                               
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="true">                            
                            <Setter Property="Background" TargetName="ListItemContainer" Value="{DynamicResource AxisValueSelectedBackground}"/>
                            <Setter Property="Foreground" Value="{DynamicResource AxisValueSelectedForeground}"/>
                        </Trigger>

                        <Trigger Property="IsSelected" Value="false">
                            <Setter Property="Background" TargetName="ListItemContainer" Value="{DynamicResource AxisValueBackground}"/>
                            <Setter Property="Foreground" Value="{Binding IsEnabled, Converter={StaticResource AxisValueForegroundConverter}}" />
                            <Setter Property="FontStyle" Value="{Binding IsEnabled, Converter={StaticResource AxisValueFontStyleConverter}}" />
                        </Trigger>

                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding …
Run Code Online (Sandbox Code Playgroud)

wpf virtualization listbox

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

HTTPS而不是HTTP?

我是网络安全的新手.

为什么我要使用HTTP然后切换到HTTPS进行某些连接?

为什么不一直坚持使用HTTPS?

https web-applications http

12
推荐指数
3
解决办法
1829
查看次数

使用静态值填充Sitecore Droplist

我可以通过在源字段中直接指定它们来填充sitecore中的droplist,Apples|Oranges|Grapes并将它们显示在模板上,而不是实际为每个值创建项目,然后编写指向父项的查询?

sitecore sitecore6

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