Tag: C#的

错误C2275:非法使用这种types作为expression式

从昨天开始,我一直在为我的C项目面临一个编译错误。 这个项目本身就是创build一个服务来完成一些任务。 我自昨天以来没有发生什么变化,但今天早上,我的代码不能再编译了。 这里是我有的错误: c:\path\main.c(56): error C2275: 'SERVICE_TABLE_ENTRY' : illegal use of this type as an expression c:\program files\microsoft sdks\windows\v7.0a\include\winsvc.h(773) : see declaration of 'SERVICE_TABLE_ENTRY' c:\path\main.c(56): error C2146: syntax error : missing ';' before identifier 'DispatchTable' c:\path\main.c(56): error C2065: 'DispatchTable' : undeclared identifier c:\path\main.c(56): error C2059: syntax error : ']' c:\path\main.c(57): error C2065: 'DispatchTable' : […]

替代多个String.Replaces

我的代码连续几次使用String.Replace : mystring = mystring.Replace("somestring", variable1); mystring = mystring.Replace("somestring2", variable2); mystring = mystring.Replace("somestring3", variable1); 我怀疑有一个更好更快的方法来做到这一点。 你会build议什么?

为什么我们不允许在接口中指定构造函数?

可能重复: 定义构造函数签名的接口? 我知道你不能在.Net的接口中指定一个构造函数,但为什么我们不能呢? 对于我目前的项目来说,能够指定必须使用构造函数传入一个“引擎”是非常有用的,但是因为我不能,所以我必须对该类有一个XML注释。

为什么写'sizeof(char)`如果字符是1是标准的?

我正在做一些C编码,阅读了一些C代码后,我注意到有代码片段 char *foo = (char *)malloc(sizeof(char) * someDynamicAmount); 所以我想问问什么更多的C – ISH方式来分配char数组的内存? 使用sizeof(char)并假定代码是针对任何标准更改的代码,或省略它并直接使用该数字?

如何使用EF Core在ASP.NET Core中取消应用迁移

当我使用EF Core在VS2015中运行PM> Remove-Migration -context BloggingContext ,出现以下错误: System.InvalidOperationException: The migration '20160703192724_MyFirstMigration' has already been applied to the database. Unapply it and try again. If the migration has been applied to other databases, consider reverting its changes using a new migration. at Microsoft.EntityFrameworkCore.Migrations.Design.MigrationsScaffolder.RemoveMigration(String projectDir, String rootNamespace, Boolean force) at Microsoft.EntityFrameworkCore.Design.MigrationsOperations.RemoveMigration(String contextType, Boolean force) at Microsoft.EntityFrameworkCore.Tools.Cli.MigrationsRemoveCommand.<>c__DisplayClass0_0.<Configure>b__0() at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] […]

文件从一个文件夹计数

如何从C#使用ASP.NET获取文件夹的数量?

在.Net Compact Framework中读取文件内容

我正在开发一个移动设备的.net紧凑框架2.0的应用程序。 我正试图加载文件的内容到一个string对象,但不知何故我无法完成。 System.IO.StreamReader类中没有ReadToEnd()方法。 是否有另一个类提供这个function?

Linq OrderByDescending,null为空

我在我的数据库中有一个字段包含DateTime ?. 我想对结果进行sorting,使NULL显示在顶部,然后按DateTime递减,例如, null null 2012-04-01 2012-01-01 2011-09-04 原因是我在看过期date,虽然有些条目不会过期。

如何检查inputIP落在特定的IP范围内

如果我们让用户input几个IP范围,例如172.16.11.5 – 100,我怎么能写一个函数来检查一个IP(172.16.11.50)是否在这个范围内? .NET中有没有现有的库可以利用?

预处理器指令#if和#ifdef之间的区别

两个预处理器控制语句之间有什么区别(如果有的话)。 #if 和 #ifdef