我有一个简单的.NET应用程序,它作为Windows服务运行.说它有一个类
MyClass
{
Run(Destination d)
Walk(Destination d)
Wash(Dishes d)
}
Run Code Online (Sandbox Code Playgroud)
我想创建一个控制台应用程序,我会在其中键入简单的人类可读命令
run left
walk right
Run Code Online (Sandbox Code Playgroud)
就像你在Windows控制台中一样.我想知道实现这种映射的最佳方法是什么.直接的方法当然是创建自己的字符串解析器,其中包含许多switch语句,但我认为如果有更好更快的方法.
我有WinForms应用程序.My Form派生类具有UserControl派生类.我只是将几个控件放入一个UserControl中以简化重用.该Load事件UserControl不被解雇.我必须设置一些房产吗?
我有传统的C#代码,我使用Visual Studio 2008年.我要寻找一个工具,排序的代码分析工具,会对我说哪一个类中未使用,也有一些其他有用的信息,可能对代码优化非常有用.
如果有确切的重复,请注明.
谢谢.
我有一个WCF服务和Web客户端.Web服务实现一种方法SubmitOrders.此方法采用订单集合.问题是服务必须为每个订单返回一个结果数组 - true或false.将WCF参数标记为out或ref毫无意义.你会推荐什么?
[ServiceContact]
public bool SubmitOrders(OrdersInfo)
[DataContract]
public class OrdersInfo
{
Order[] Orders;
}
Run Code Online (Sandbox Code Playgroud) 我需要将一些数据序列化为字符串.然后将该字符串存储在特殊列SerializeData中的DB中.
我创建了用于序列化的特殊类.
[Serializable]
public class SerializableContingentOrder
{
public Guid SomeGuidData { get; set; }
public decimal SomeDecimalData { get; set; }
public MyEnumerationType1 EnumData1 { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
连载:
protected override string Serialize()
{
SerializableContingentOrder sco = new SerializableContingentOrder(this);
MemoryStream ms = new MemoryStream();
SoapFormatter sf = new SoapFormatter();
sf.Serialize(ms, sco);
string data = Convert.ToBase64String(ms.ToArray());
ms.Close();
return data;
}
Run Code Online (Sandbox Code Playgroud)
反序列化:
protected override bool Deserialize(string data)
{
MemoryStream ms = new MemoryStream(Convert.FromBase64String(data).ToArray());
SoapFormatter sf = new SoapFormatter();
SerializableContingentOrder sco = …Run Code Online (Sandbox Code Playgroud) 我有一个简单的任务,我需要检查一个字典中的对象,如果满足某些条件移动到另一个.我问的是,如果有一些好的模式,我可以使用语言功能来实现这一点.直接的方法很简单 - 使用临时收集,第一步确定canditates,第二步做实际移动.没关系,但不酷.
目前的代码
class Order
{
public int ID;
public bool IsReady;
}
Dictionary<int, Order> ActiveDictionary;
Dictionary<int, Order> ProcessedDictionary;
public Update()
{
// temporary list, uncool
List<Order> processed = new List<Order>();
// fist step
foreach(Order ord in ActiveDictionary)
{
if(ord.IsReady)
{
processed.Add(ord);
}
}
// ok now lets move
foreach(Order ord in processed)
{
ActiveDictionary.Remove(ord.ID);
ProcessedDictionary.Add(ord.ID, ord);
}
}
Run Code Online (Sandbox Code Playgroud) 我使用SortedDictionary来存储按整数排序的值.
我需要在特定的现有整数后得到下一个值.我更喜欢使用枚举器,但没有GetEnumerator(Key k)或类似的功能.
SortedDictionary<int, MyClass> _dict;
void GetNextValue(int start, out MyClass ret)
{
}
Run Code Online (Sandbox Code Playgroud) 我有.NET服务(C#),它使用了几个c ++库.我迫切需要进入C++方法,但是当我设置断点时,它们会在运行时被禁用.
在哪看?
我在C++项目设置中设置了"Attach Debugger",但这似乎没有改变.
请指教.在哪看?
如果有人关心,这些库是quickfix引擎.
我想确定我的应用程序的巨大内存消耗的来源.我的应用程序正在占用大量虚拟内存(任务管理器中的VM列或VMMap中的专用字节)
我的应用程序是.net服务,但它使用C#包装器围绕C++对象.
我尝试过Red Gate Ants Memory分析器,但它只计算托管对象,并且不计算由非托管C++ new运算符分配的内存(它只是调用Virtual Alloc).
托管内存分析器的另一个问题是不允许跟踪调用图 - 请参见下图.


我有一些有很多领域的课;
public class CrowdedHouse
{
public int value1;
public float value2;
public Guid value3;
public string Value4;
// some more fields below
}
Run Code Online (Sandbox Code Playgroud)
我的类必须按以下格式(de)序列化为简单的Windows文本文件
NAME1=VALUE1
NAME2=VALUE2
Run Code Online (Sandbox Code Playgroud)
在.NET中最方便的方法是什么?这是一个文本文件,所有值必须先将其转换为字符串.假设我已经将所有数据转换为字符串.
更新一个选项是pinvoke WritePrivateProfileString/WritePrivateProfileString,但这些是使用我不需要使用的所需"[Section]"字段.
c# ×10
.net ×7
algorithm ×1
c++ ×1
collections ×1
debugging ×1
dictionary ×1
events ×1
file ×1
new-operator ×1
parsing ×1
profiler ×1
scripting ×1
text ×1
versioning ×1
winforms ×1