小编use*_*677的帖子

IEnumerable到字符串

我有一个返回的DataTable

IDs
,1
,2
,3
,4
,5
,100
,101
Run Code Online (Sandbox Code Playgroud)

我想将其转换为单个字符串值,即:

,1,2,3,4,5,100,101
Run Code Online (Sandbox Code Playgroud)

如何重写以下内容以获取单个字符串

var _values = _tbl.AsEnumerable().Select(x => x);
Run Code Online (Sandbox Code Playgroud)

c# linq asp.net datatable ado.net

38
推荐指数
3
解决办法
6万
查看次数

接口事件的实际使用

什么是接口事件的强大功能(在接口内声明事件)?

大多数时候我只看到界面内部的公共抽象方法.

c# events delegates interface

30
推荐指数
4
解决办法
4万
查看次数

C# - StringDictionary - 如何使用单个循环获取键和值?

我正在使用StringDictionary集合来收集Key Value Pairs.

例如:

StringDictionary KeyValue = new StringDictionary();
KeyValue.Add("A", "Load");
KeyValue.Add("C", "Save");
Run Code Online (Sandbox Code Playgroud)

在检索过程中,我必须形成两个foreach来获取键和值(即)

foreach(string key in KeyValue.Values)
{
   ...
}

foreach(string key in KeyValue.Keys)
{
   ...
}
Run Code Online (Sandbox Code Playgroud)

有没有办法让这对搭配单身foreach

c# collections

21
推荐指数
2
解决办法
6万
查看次数

C# - 委托System.Func <>

如何使用委托System.Func <>?我们应该使用它控制funcion或事件的执行顺序吗?

简单的例子会有所帮助

c#

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

使用LINQ获得对集

当我有一个清单

IList<int> list = new List<int>();
list.Add(100);
list.Add(200);
list.Add(300);
list.Add(400);
list.Add(500);
Run Code Online (Sandbox Code Playgroud)

提取对的方法是什么

Example : List elements {100,200,300,400,500}

Expected Pair : { {100,200} ,{200,300} ,{300,400} ,{400,500} }
Run Code Online (Sandbox Code Playgroud)

c# linq

17
推荐指数
3
解决办法
7911
查看次数

C# - 匿名代表

像匿名方法一样,我宣布使用"delegate"关键字的代表是匿名代表吗?

namespace Test
{
    public delegate void MyDelegate();
    class Program
    {
        static void Main(string[] args)
        {
            DelegateTest tst = new DelegateTest();
            tst.Chaining();
            Console.ReadKey(true);
        }
    }

    class DelegateTest
    {
        public event MyDelegate del;

        public void Chaining()
        {
            del += delegate { Console.WriteLine("Hello World"); };
            del += delegate { Console.WriteLine("Good Things"); };
            del += delegate { Console.WriteLine("Wonderful World"); };
            del();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

c# delegates

17
推荐指数
2
解决办法
3万
查看次数

计算两个列表中所有可能的项目对?

我有两个数组:

string[] Group = { "A", null, "B", null, "C", null };

string[] combination = { "C#", "Java", null, "C++", null }; 
Run Code Online (Sandbox Code Playgroud)

我希望返回所有可能的组合,例如:

{ {"A","C#"} , {"A","Java"} , {"A","C++"},{"B","C#"},............ }
Run Code Online (Sandbox Code Playgroud)

应该忽略null.

.net c# linq combinations

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

什么是类图中的"派生属性"?

我正在阅读一个类图.类中的一些属性标有斜杠"/"ex ( / -accountBalance:Dollar = 0 ).

当我们说"派生属性"时,我们是指它是枚举还是其他类实例(通常是自定义数据类型)?

uml class-diagram

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

有没有可用的UML参考卡?

是否有可用于UML的参考卡或备忘单?

oop uml

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

代表和回调

在委托的上下文中,术语回调是否意味着" 代理委托它为另一个代表工作以完成某项任务 "?

示例:( 根据我的理解,我已经实现了回调,如果错误则纠正我)

namespace Test
{
    public delegate string CallbackDemo(string str);  

    class Program
    {
        static void Main(string[] args)
        {
            CallbackDemo handler = new CallbackDemo(StrAnother);
            string substr = Strfunc(handler);
            Console.WriteLine(substr);
            Console.ReadKey(true);
        }

        static string Strfunc(CallbackDemo callback)
        {
           return callback("Hello World");   
        }

        static string StrAnother(string str)
        {
            return str.Substring(1, 3).ToString();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

请根据需要提供示例.

c# callback

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