草庐IT

Non-declaration

全部标签

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# - C++/命令行界面 : How do I declare abstract (in C#) class and method in C++/CLI?

以下C#代码在C++/CLI中的等价物是什么?publicabstractclassSomeClass{publicabstractStringSomeMethod();} 最佳答案 只需稍微混合关键字即可获得正确的语法。abstract在C#中位于前面,但在C++/CLI中位于末尾。与override关键字相同,今天也被C++11兼容的编译器识别,它们期望它位于函数声明的末尾。就像传统C++中的=0标记函数抽象一样:publicrefclassSomeClassabstract{public:virtualString^SomeM

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# - Visual Studio 2015 中是否有用于 C# 的 "Go To Variable Type Declaration"函数或一个免费插件?

voidMagicalFunction(MagicalTypemagic){...magic.Poof("something");...varfoo=magic.GetFoo();...}在变量magic上按下热键将导航到类型MagicalType的定义。在foo上按下热键将转到类型Foo的定义,由于类型推断,它在这里不直接可见。Resharper插件具有此功能(称为GoToTypeofSymbol),但是是否有内置的替代方案或免费扩展来执行此操作? 最佳答案 右键单击“var”关键字,从上下文菜单中选择“Gotodefinitio

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# - "The ' http ://www. w3.org/XML/1998/namespace:lang ' attribute is not declared."

有时,在使用XmlValidatingReader验证某些XML文档时,我收到以下错误:System.Xml.Schema.XmlSchemaValidationException:"The'http://www.w3.org/XML/1998/namespace:lang'attributeisnotdeclared."同一个文档有时会成功。我不明白为什么。我的XSD像这样导入架构:...在XML文档中我有以下属性:最后,XmlReaderSettings:constXmlSchemaValidationFlagsvalidationFlags=XmlSchemaValidation

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# - .NET 属性生成 "must declare a body because it is not marked abstract or extern"编译错误

我有一个.NET3.5(目标框架)网络应用程序。我有一些看起来像这样的代码:publicstringLogPath{get;privateset;}publicstringErrorMsg{get;privateset;}它给我这些行的编译错误:"mustdeclareabodybecauseitisnotmarkedabstractorextern."有什么想法吗?我的理解是这种风格的属性在.NET3.0中是有效的。谢谢!原来问题出在我的.sln文件本身。尽管我在构建选项中更改了目标版本,但在.sln文件中,我发现了这一点:TargetFramework="3.0"将其更改为“3.5

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]