小编KCS*_*KCS的帖子

删除Dictionary键中的重复项

我有下面的字典:

Dictionary<string, string> test = new Dictionary<string, string>();
test.Add("1|1", "blue");
test.Add("1|2", "Nice");
test.Add("1|3", "Jaish");
test.Add("2|2", "Muna");
test.Add("3|1", "haha");
test.Add("3|2", "green");
test.Add("4|1", "red");
Dictionary<string, string> test2 = new Dictionary<string, string>();
foreach (KeyValuePair<string, string> entry in test)
{
    if (!test2.ContainsValue(entry.Key))
        test2.Add(entry.Key, entry.Key);
}
Run Code Online (Sandbox Code Playgroud)

我想删除以下重复值:

test.Add("1|2", "Nice");
test.Add("1|3", "Jaish");
test.Add("3|2", "green")
Run Code Online (Sandbox Code Playgroud)

因此,删除重复项后,Dictionary密钥计数应为4.

c#

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

对WPF中项目集合的可见性

我有下拉和网格.在网格列中有超链接.如果Dropdown集合包含1个项目,则下拉列表应该是不可见的.我需要一个逻辑来将Visibility绑定到项目集合.

这是GRid中一个超链接的XAML.

   <!--Associate-->
                    <TextBlock Margin="10, 0, 0, 0">                                    
                        <TextBlock.Visibility>                                           
                                 <MultiBinding Converter="{StaticResource courseListVisibilityConverter}"
                                                     ConverterParameter="Associate">
                                          <Binding Path="IsCourseAssocited"
                                                   RelativeSource="{RelativeSource Mode=FindAncestor,AncestorType={x:Type DPA2:TakenCoursesNotApplied}}" />
                                            <Binding Path="DataContext"
                                                     RelativeSource="{RelativeSource Self}" />
                                       </MultiBinding>
                            </TextBlock.Visibility>

                        <Hyperlink DataContext="{Binding}"
                                   Name="Associate"
                                    IsEnabled="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type TextBlock}}, Path=IsVisible}"
                                    Click="Associate_Click">
                            <TextBlock TextWrapping="Wrap"
                                        Text="Associate" />
                        </Hyperlink>
                    </TextBlock>

 public class CourseListVisibilityConverter : IMultiValueConverter
{
    public object Convert(object[] value, Type targetType, object parameter, CultureInfo culture)
    {
        if (value == null || value[0] == null || value[1] == null) return Visibility.Collapsed;
        bool IsEditMode = value[0] == DependencyProperty.UnsetValue ? …
Run Code Online (Sandbox Code Playgroud)

c# wpf grid imultivalueconverter

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

正则表达日期在19000101到20001231之间

任何机构可以建议REGX低于日期范围

格式为CCYYMMDD 19000101至20001231空白

我是REGX的新手,请帮帮我.

c#

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

标签 统计

c# ×3

grid ×1

imultivalueconverter ×1

wpf ×1