小编bra*_*don的帖子

应用之间的对象共享?

假设我的大数据阵列每秒更新1000次以上.
另一个应用程序想要在短时间内访问和读取数组.两个应用程序都在同一台机器上.

我已经尝试使用WCF进行进程间通信,但是每秒数千次序列化和发送整个数组(或大型对象)是不可行的性能.
有没有办法直接访问c#中不同应用程序的对象?

c# object sharing interprocess

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

检查类型的最快方法是什么?

我决定在一个函数中检查类型,而不是将函数重载100次或为不同类型创建100个不同的比较器.

例如,我使用默认比较器来比较2个对象中的一组类型(基元和字符串)的值.它包含以下代码:

public class DefComparer : IComparer<object> {
    public int Compare(object a, object b) {
        .... // a = a.GetType().GetField(field).GetValue(a); - not important for the question but I'm just showing that a&b below are different references
        switch (a.GetType().Name) {
            case "Byte":
                if ((byte)a == (byte)b) return 0;
                else if ((byte)a > (byte)b) return 1;
                else return -1;
            case "UInt16":
                if ((ushort)a == (ushort)b) return 0;
                else if ((ushort)a > (ushort)b) return 1;
                else return -1;
            case "SByte":
                if ((sbyte)a == …
Run Code Online (Sandbox Code Playgroud)

c# reflection performance types

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

如何创建命名引用类型元组?

以下行创建一个命名ValueTuple:

var tuple = (a:1, b:2, c:3, d:4, e:5, f:6);  
Run Code Online (Sandbox Code Playgroud)

值类型无法有效传递.是否C#7提供了创建该Tuple类型的命名元组的方法?

c# tuples reference-type named c#-7.0

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