In my form I am doing something as simple as private void btnPrintPickList_Click(object sender, EventArgs e) { using (var salesRpt = new SalesOrder(CurrentItem())) { salesRpt.CreateSpreadSheet(); salesRpt.Dispose(); } } I have followed the "no 2 dots rule for excel interop". protected ExcelSheet(bool documentVisible, XlPageOrientation orientation) { Ex
在我的形式中,我正在做一些简单的事情 private void btnPrintPickList_Click(object sender, EventArgs e) { using (var salesRpt = new SalesOrder(CurrentItem())) { salesRpt.CreateSpreadSheet(); salesRpt.Dispose(); } } 我遵循了“为excel互操作而设计的2点规则”。 protected ExcelSheet(bool documentVisible, XlPageOrientation orientation) { ExcelApplication = new Application
Given the following XML example we could imagine a schema defining Root as containing a sequence of unbound number of choices between Type1 and Type2. <Root> <Type1 /> <Type2 /> <Type2 /> <Type1 /> </Root> I am testing out migrating from the XSD.exe tool which although adds type-safety has a lot of little annoyances. The XSD tool in this case
给定以下XML示例,我们可以将一个定义Root的模式想象为包含Type1和Type2之间的一系列未绑定选项。 <Root> <Type1 /> <Type2 /> <Type2 /> <Type1 /> </Root> 我正在测试从XSD.exe工具迁移出来,尽管这种工具增加了类型安全性,但却有许多小小的烦恼。 在这种情况下,XSD工具只是在Root中创建一个System.Object类型的数组,并且必须确定其中存在哪些类型的对象(Type1或T
I have a waveform 64 samples long. If the sampling rate is 44100 hz, how can I play(loop) this waveform so that it plays arbitrary frequencies? frequency = samplerate / waveform duration in samples Therefore the frequency should be 689hz(44100/64). If I wanted it to be say, 65.41hz(C-2), I would have to do this: 65.41 = 44100 / x Solving for x yields aprox. 674.208. So I need to figur
我有一个64个样本的波形。 如果采样率是44100赫兹,我怎么能播放(循环)这个波形,以便它播放任意频率? 频率=样本中的采样率/波形持续时间 因此频率应该是689hz(44100/64)。 如果我想说的是,65.41hz(C-2),我将不得不这样做: 65.41 = 44100 / x 求解x产生aprox。 674.208。 所以我需要弄清楚在什么速度下播放波形来获得这个频率。 所以我们可以解决这个方程: 64 * x = 674.208 并获得约10.5。 所以波
I'm using the Northwind database as an example for this post where I am having a problem saving detached entities back to the database using the entity framework. I have the following two methods to get me the territories and the regions: static List<Region> GetRegions() { using (NorthwindEntities entities = new NorthwindEntities()) { entities.Regi
我正在使用Northwind数据库作为这篇文章的一个例子,我在使用实体框架将分离的实体保存回数据库时遇到了问题。 我有以下两种方法可以让我获得领土和地区的信息: static List<Region> GetRegions() { using (NorthwindEntities entities = new NorthwindEntities()) { entities.Region.MergeOption = System.Data.Objects.MergeOption.NoTracking; return entities.Reg
I have a list of 500000 randomly generated Tuple<long,long,string> objects on which I am performing a simple "between" search: var data = new List<Tuple<long,long,string>>(500000); ... var cnt = data.Count(t => t.Item1 <= x && t.Item2 >= x); When I generate my random array and run my search for 100 randomly generated values of x , the searches comple
我有一个500000个随机生成的Tuple<long,long,string>对象的列表,我正在其上执行一个简单的“between”搜索: var data = new List<Tuple<long,long,string>>(500000); ... var cnt = data.Count(t => t.Item1 <= x && t.Item2 >= x); 当我生成我的随机数组并运行我的搜索以获得100个随机生成的x值时,搜索将在大约4秒内完成。 但是,我知道排序对搜索有很大的好处,因此我决定先排序我的数
I have a class like this and to this type I need to deserialize a JSON string public class nodes { public int id{get;set;} public string name{get;set;} public List<nodes> children{get;set;} } and the JSON is like this { id: 15, name: 'user1', children: [ { id: 22, name: 'user2', children: [ { id: 34, name: 'user3',
我有这样的类和这种类型我需要反序列化一个JSON字符串 public class nodes { public int id{get;set;} public string name{get;set;} public List<nodes> children{get;set;} } 而JSON就是这样 { id: 15, name: 'user1', children: [ { id: 22, name: 'user2', children: [ { id: 34, name: 'user3', children: [ {
I've seen a few different ways to iterate over a Dictionary in C#. Is there a standard way? foreach(KeyValuePair<string, string> entry in myDictionary) { // do something with entry.Value or entry.Key } If you are trying to use a generic Dictionary in C# like you would use an associative array in another language: foreach(var item in myDictionary) { foo(item.Key); bar(item.Va
我已经看到了几种不同的方法来遍历C#中的Dictionary。 有没有标准的方法? foreach(KeyValuePair<string, string> entry in myDictionary) { // do something with entry.Value or entry.Key } 如果您正在尝试在C#中使用通用字典,就像使用其他语言的关联数组一样: foreach(var item in myDictionary) { foo(item.Key); bar(item.Value); } 或者,如果您只需要迭代密钥集合,请使用 foreach(var item in m
In this question, someone suggested in a comment that I should not cast the result of malloc , ie int *sieve = malloc(sizeof(int) * length); rather than: int *sieve = (int *) malloc(sizeof(int) * length); Why would this be the case? No ; you don't cast the result, since: It is unnecessary, as void * is automatically and safely promoted to any other pointer type in this case. It add
在这个问题上,有人在评论,我不应该投的结果提出malloc ,即 int *sieve = malloc(sizeof(int) * length); 而不是: int *sieve = (int *) malloc(sizeof(int) * length); 为什么会这样呢? 不 ; 你不会投出结果,因为: 这是没有必要的,因为在这种情况下void *被自动且安全地提升为任何其他指针类型。 它给代码增加了混乱,转换不太容易阅读(特别是如果指针类型很长)。 它让你重复自己,这通常是不好的。 如
I have some code and when it executes, it throws a NullReferenceException , saying: Object reference not set to an instance of an object. What does this mean, and what can I do to fix this error? What is the cause? Bottom Line You are trying to use something that is null (or Nothing in VB.NET). This means you either set it to null , or you never set it to anything at all. Like anythi
我有一些代码,当它执行时,它会抛出一个NullReferenceException ,并说: 你调用的对象是空的。 这是什么意思,我能做些什么来解决这个错误? 原因是什么? 底线 您试图使用null (或VB.NET中的Nothing )。 这意味着你要么将它设置为null ,要么你根本没有设置它。 像其他任何东西一样, null传递。 如果它在方法“A”中为null ,则可能是该方法“B”将null传递给方法“A”。 本文的其余部分会更详细地介绍并显示许
I have been searching the web looking for a definition for declarative and imperative programming that would shed some light for me. However the language used at some of the resources that I have found is daunting - for instance at Wikipedia. Does any one have a real world example that they could show me that might bring some perspective to this subject... perhaps in C#. A great C# example of
我一直在寻找网络寻找一个声明和命令式编程的定义,这将为我提供一些启示。 然而,我发现的一些资源所使用的语言令人望而生畏,例如维基百科。 有没有人有一个真实世界的例子,他们可以告诉我可能会给这个主题带来一些观点......也许在C#中。 声明式与命令式编程的一个很好的C#示例是LINQ。 通过命令式编程,您可以一步一步地告诉编译器您想要发生的事情。 例如,让我们从这个集合开始,然后选择奇数: List<int>