草庐IT

non-constant

全部标签

c++ - MinGW C++ : Reading a file with non-ascii file name

简单任务:我想读取一个文件名不是ascii的文件。在linux和MacOS上,我只是将文件名作为UTF-8编码字符串传递给fstream构造函数。在Windows上,这会失败。正如我从thisquestion中了解到的那样,windows根本不支持utf-8文件名。但是,它提供了一个自己的非标准open方法,该方法采用utf-16wchar_t*。因此,我可以简单地将我的string转换为utf-16wstring并且没问题。然而,在MinGW标准库中,fstream的wchar_t*open方法根本不存在。那么,如何在MinGW上打开一个非ascii文件名?

c# - 为什么我不能在范围内的 switch 语句中使用 "constant"?

使用这段代码:publicpartialclassForm1:Form{privatestaticreadonlyintTABCONTROL_BASICINFO=0;privatestaticreadonlyintTABCONTROL_CONFIDENTIALINFO=1;privatestaticreadonlyintTABCONTROL_ROLESANDSECURITY=2;privatestaticreadonlyintTABCONTROL_INACTIVEINFO=3;...intActiveTabPage=tabControlWorker.SelectedIndex;swit

c# - 数字必杀技 : Where does a callvirt of a non-existent method end up?

我在其基类中标记为抽象的库类上调用属性集访问器。现在在运行时我force应用程序针对另一个版本的库运行,其中类仅实现基类的底层接口(interface),但不是从它派生的。有趣的是,.NET将运行代码,但设置该属性没有任何效果。幕后发生了什么?违规代码:MyDbParameterparam=newMyDbParameter();param.ParameterName="p";Console.Out.WriteLine("ParameterName:"+param.ParameterName);库2.0(已编译)publicsealedclassMyDbParameter:System.

c# - CodeContracts : Boolean condition evaluates to a constant value, 为什么?

我收到此警告但无法找出问题...CodeContracts:warning:TheBooleanconditiond1.Count!=d2.Countalwaysevaluatestoaconstantvalue.Ifit(oritsnegation)appearinthesourcecode,youmayhavesomedeadcodeorredundantcheck代码如下:publicstaticboolDictionaryEquals(IDictionaryd1,IDictionaryd2){if(d1==d2)returntrue;if(d1==null||d2==null)

c# - Lazy<T> 延迟加载错误 : A field initializer cannot reference the non-static field, 方法或属性

我第一次尝试使用延迟加载来初始化我的类中的进度对象。但是,我收到以下错误:Afieldinitializercannotreferencethenon-staticfield,method,orproperty.privateLazym_progress=newLazy(()=>{longtotalBytes=m_transferManager.TotalSize();returnnewProgress(totalBytes);});在.NET2.0中,我可以执行以下操作,但我更愿意使用更新的方法:privateProgressm_progress;privateProgressPro

c# - LINQ to SQL insert-if-non-existent

我想知道是否有更简单的方法来插入表中尚不存在的记录。我仍在努力培养我的LINQtoSQL技能。这是我得到的,但似乎应该有更简单的方法。publicstaticTEntityInsertIfNotExists(DataContextdb,Tabletable,Funcwhere,TEntityrecord)whereTEntity:class{TEntityexisting=table.SingleOrDefault(where);if(existing!=null){returnexisting;}else{table.InsertOnSubmit(record);//Can'tuse

c# - Exchange Web 服务 : why is ItemId not constant?

我写了一个小应用程序,它应该自动处理来自公用文件夹的电子邮件。对于每封电子邮件,我们希望在数据库中保存一些元数据。我想使用ItemID来建立此元数据和特定电子邮件之间的链接,但我刚刚发现此ItemId不是常量。例如,如果电子邮件从公共(public)文件夹移动到另一个文件夹,它将收到另一个ItemId。这意味着电子邮件和相关元数据之间的链接丢失了。那么,问题是,如何在元数据和特定电子邮件之间建立链接? 最佳答案 我的理解是,EWS唯一ID包含某种形式的EntryId。因此,一旦元素移动到另一个文件夹,它就会发生变化。虽然此处不适用,

c# - The non-generic method cannot be used with type arguments in this context 是什么意思?

我有以下类和方法:publicclassUserManager:IDisposablewhereTUser:class,global::Microsoft.AspNet.Identity.IUserwhereTKey:global::System.IEquatable{publicvirtualTaskFindByIdAsync(TKeyuserId);和:privateApplicationUserManager_userManager;publicApplicationUserManagerUserManager{get{return_userManager??Request.Ge

c# - TDD : Any pattern for constant testing?

常量是美丽的人——它们可以在一个独特的地方保存一个在代码中随处使用的值。更改该值只需要一个简单的修改。生活很酷。嗯,这是promise。现实有时是不同的:您将LogCompleteFileName常量值从L:\LOGS\MyApp.log更改为\\Traces\App208.txt并且您得到两个文件:用于跟踪的\\traces\App208.txt和用于日志的\\traces\App208.txt.log...您将TransactionTimeout从2分钟更改为4分钟,但在2分钟后您仍然会超时(在花费了一天之后,您发现您还必须更改DBMS的超时和超时交易经理...)。您将SleepT

c# - Entity Framework : Alternate solution to using non primary unique keys in an association

我知道EntityFramework不允许您使用非主唯一键作为外键关联从数据库生成模型。我可以手动修改EDMX吗?如果是这样,有人可以给我一个例子或引用吗?如果不是,还有其他可能吗?最简单的例子:这是表的DDL。您会注意到我有一个从PersonType.TypeCode到Person.TypeCode的外键CREATETABLE[dbo].[PersonType]([PersonTypeId][int]NOTNULL,[TypeCode][varchar](10)NOTNULL,[TypeDesc][varchar](max)NULL,CONSTRAINT[PK_PersonType]