假设我的大数据阵列每秒更新1000次以上.
另一个应用程序想要在短时间内访问和读取数组.两个应用程序都在同一台机器上.
我已经尝试使用WCF进行进程间通信,但是每秒数千次序列化和发送整个数组(或大型对象)是不可行的性能.
有没有办法直接访问c#中不同应用程序的对象?
我决定在一个函数中检查类型,而不是将函数重载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) 以下行创建一个命名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# ×3
c#-7.0 ×1
interprocess ×1
named ×1
object ×1
performance ×1
reflection ×1
sharing ×1
tuples ×1
types ×1