小编Dag*_*oms的帖子

在C#中读取和解析Json文件

我已经花了两天时间对代码样本等进行"最好的"工作,尝试将一个非常大的JSON文件读入c#中的数组中,以便稍后将其拆分为二维数组进行处理.

我遇到的问题是我找不到任何人做我想做的事情的例子.这意味着我只是想编写一些希望最好的代码.

我已经成功地完成了一些工作:

  • 读取文件Miss out headers并仅将值读入数组.
  • 在数组的每一行上放置一定数量的值.(所以我以后可以把它分成2d数组)

这是通过下面的代码完成的,但是在输入几行到数组后它会崩溃程序.这可能与文件大小有关.

// If the file extension was a jave file the following 
// load method will be use else it will move on to the 
// next else if statement
if (fileExtension == ".json") 
{
    int count = 0;
    int count2 = 0;
    int inOrOut = 0;
    int nRecords=1; 
    JsonTextReader reader = new JsonTextReader(new StreamReader(txtLoaction.Text));
    string[] rawData = new string[5];
    while (reader.Read())
    {
        if (reader.Value != null)
            if (inOrOut == 1)
            {
                if …
Run Code Online (Sandbox Code Playgroud)

c# parsing json large-files

207
推荐指数
9
解决办法
49万
查看次数

如何将向量传递给函数?

我正在尝试将向量作为参数发送到函数,我无法弄清楚如何使其工作.尝试了一堆不同的方法,但他们都给出了不同的错误信息.我只包含部分代码,因为只有这部分不起作用.(向量"随机"填充了0到200之间的随机但排序的值)

更新了代码:

#include <iostream>     
#include <ctime>        
#include <algorithm>    
#include <vector>       

using namespace std;

int binarySearch(int first, int last, int search4, vector<int>& random);

int main()
{
    vector<int> random(100);

    int search4, found;
    int first = 0;
    int last = 99;

    found = binarySearch(first, last, search4, random);

    system("pause");    
    return(0);      
}

int binarySearch(int first, int last, int search4, vector<int>& random)
{
    do
    {
        int mid = (first + last) / 2;  
        if (search4 > random[mid]) 
            first = mid + 1;  
        else if (search4 < …
Run Code Online (Sandbox Code Playgroud)

c++ function vector

82
推荐指数
2
解决办法
25万
查看次数

没有这样的表错误

我不得不搜索关于这些错误的很多帖子,但我仍然无法解决问题.这是我的代码,谁能帮助我看看出了什么问题?

- (void) copyDatabaseIfNeeded {


    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
   NSString *path = [documentsDirectory stringByAppendingPathComponent:@"SQL.sqlite"];

    if (sqlite3_open([path UTF8String], &newDBconnection) == SQLITE_OK) 
    {
        NSLog(@"Database opened successfully");

if(updateStmt == nil) {
            NSString *updStmt = [NSString stringWithFormat: @"UPDATE Coffee SET CoffeeName = '500 Plus', Price = '1.40' Where CoffeeID= '3'"];
   const char *mupdate_stmt = [updStmt UTF8String]; 

if(sqlite3_prepare_v2(newDBconnection, mupdate_stmt, -1, &updateStmt, NULL) != SQLITE_OK){
NSAssert1(0, @"Error while creating update statement. '%s'", sqlite3_errmsg(newDBconnection));
            } else {
                NSLog(@"Update successful");
            } …
Run Code Online (Sandbox Code Playgroud)

sqlite xcode4

16
推荐指数
1
解决办法
6万
查看次数

将滚动事件附加到div与body on()绑定失败

滚动事件我遇到了一些麻烦.

我正在尝试将事件附加/绑定到特定的div,并且我正在使用$('body').on()它,因为在排序时内容被重新加载,因此它将失去其绑定.

这不起作用,事件未被触发:

$('body').on('scroll', 'div.dxgvHSDC + div', function () {
}
Run Code Online (Sandbox Code Playgroud)

这另一方面起作用:

$('body').on('mousewheel DOMMouseScroll', 'div.dxgvHSDC + div', function () {
}
Run Code Online (Sandbox Code Playgroud)

这也是:

$('div.dxgvHSDC + div').on('scroll', function () {
}
Run Code Online (Sandbox Code Playgroud)

有什么问题?

javascript jquery events binding scroll

13
推荐指数
2
解决办法
3万
查看次数

无法解决dll之间的冲突

在我的构建中,我收到了类似于以下内容的警告墙:

No way to resolve conflict between "Newtonsoft.Json, Version=7.0.0.0" 
and "Newtonsoft.Json, Version=6.0.0.0". 
Choosing "Newtonsoft.Json, Version=7.0.0.0" arbitrarily.
Run Code Online (Sandbox Code Playgroud)

我收到以下 dll 的额外警告(重复是有意的):

Microsoft.Owin
System.Web.Http
Newtonsoft.Json
System.Net.Http.Formatting
Microsoft.Owin
Microsoft.ApplicationInsights
Run Code Online (Sandbox Code Playgroud)

以及每个警告的匹配消息:

Consider app.config remapping of assembly to solve conflict and get rid of warning.
Run Code Online (Sandbox Code Playgroud)

最后,我得到了这个冲突:

Microsoft.Common.CurrentVersion.targets Found conflicts between 
different versions of the same dependent assembly. 
Please set the "AutoGenerateBindingRedirects" property to true 
in the project file.
Run Code Online (Sandbox Code Playgroud)

我已经阅读了我可以为这些消息找到的每个堆栈溢出和 MSDN 答案。根据这个答案,最好的解决方案是将导致冲突警告的引用更改为引用相同的版本。问题似乎是来自解决方案中 53 个项目中的一些项目的程序集链依赖于不同版本的不同程序集。我无法判断哪些项目会导致这些警告,并且绑定重定向(在我检查过的每个项目中自动生成)对警告没有影响。

我该怎么做才能解决这些构建警告?

c# warnings build

7
推荐指数
2
解决办法
8721
查看次数

FabActUtil.exe以代码-1退出

我现在在包括Service Fabric包在内的所有构建上都收到以下错误:

build\Microsoft.ServiceFabric.Actors.targets(34,5): 
error MSB3073: The command ""\Build\x64\Debug\\FabActUtil.exe"
/app:"\ApplicationPackageRoot" /spp:"PackageRoot" /t:manifest /ap:"Project"
/sp:"Project1" /in:"..\Build\x64\Debug\\Project1.Exe"
/local5nodeappparamfile:"ApplicationParameters\Local.5Node.xml" 
/local1nodeappparamfile:"ApplicationParameters\Local.1Node.xml" " 
exited with code -1.
Run Code Online (Sandbox Code Playgroud)

在Service Fabric 5.2.207,SDK 2.2.207上运行

什么是FabActUtil.exe的代码-1,有没有办法在此事件上获得更好的错误输出?

azure-service-fabric

6
推荐指数
1
解决办法
1346
查看次数

.NET Standard项目构建失败,消息无用

在尝试构建面向.NET Standard 1.3(由Xamarin应用程序使用的类库)的项目时,我收到以下消息和失败的构建:

错误:您的项目未引用".NETPlatform,Version = v5.0"框架.在project.json的"frameworks"部分中添加对".NETPlatform,Version = v5.0"的引用,然后重新运行NuGet restore.

project.json这个样子的(我没有编辑它,这就是最初对我产生的):

{
  "supports": {},
  "dependencies": {
    "Microsoft.NETCore.Portable.Compatibility": "1.0.1",
    "NETStandard.Library": "1.6.0",
    "Newtonsoft.Json": "9.0.1",
    "NJsonSchema": "6.5.6190.16910"
  },
  "frameworks": {
    "netstandard1.3": {}
  }
}
Run Code Online (Sandbox Code Playgroud)

在线没有关于如何添加它要添加的引用的信息,并且它提供的值不能正常工作.

如何构建此项目?

更新:

试过这个https://github.com/dotnet/roslyn/issues/12918并且错误输出已更新为

Error : Your project is not referencing the     
".NETStandard,Version=v1.3" framework. Add a reference to 
".NETStandard,Version=v1.3" in the "frameworks" section of your 
project.json, and then re-run NuGet restore.
Run Code Online (Sandbox Code Playgroud)

更新:

我已经明白,它试图在解决方案中构建另一个项目,并提供数千个错误

未定义或导入System.Object

.net xamarin.android xamarin asp.net-core .net-standard

5
推荐指数
1
解决办法
338
查看次数

在VSTS中的.NET Core 1.1上进行Dotnet测试:没有注册测试发现者

我正在使用VS 2017与.NET标准类库中的新csproj,尝试使用带有dotnet test命令的MSTest测试框架,使用.NET Core 1.1测试项目来测试库.在当地跑步完美无缺; 当我将构建发送到持续集成时,我收到错误:

No test discoverer is registered to perform discovery of test cases.

如何在VSTS中注册此发现者并运行我的测试?

mstest vstest .net-core azure-devops dotnet-cli

5
推荐指数
1
解决办法
735
查看次数

仅在id不存在时插入

好吧,所以我们有一个带有桌面设置的phonegap应用程序

tblTest (actualid INTEGER PRIMARY KEY, id INTEGER, name TEXT)

actualid是设备的唯一ID,id保存在服务器端数据库中.我们遇到了webservices返回重复记录的问题,而我们正在修复我想要在我们的sql中添加一些东西来防止重复添加(修复坏数据很痛苦).

我们当前的插入语句设置为

INSERT INTO tblTest (id, name) VALUES (101, 'Bob')

如果你运行两次数据库将最终看起来像

actualid |  id| name
       1 | 101|  Bob
       2 | 101|  Bob
Run Code Online (Sandbox Code Playgroud)

而我希望它看起来像是

actualid |  id| name
       1 | 101|  Bob
Run Code Online (Sandbox Code Playgroud)

插入或替换会给我一个actualid 2示例和我发现使用where子句设置的任何示例

INSERT INTO tblTest SELECT ..... WHERE.....

哪个不起作用,因为没有数据在表中(除非我犯了新手错误,我不是很擅长sqlite或一般sql).

sqlite

4
推荐指数
2
解决办法
7015
查看次数

如何在iTerm2中撤消拆分面板

我已经开始使用iTerm2。我喜欢使用分割面板的功能

Cmd + d
Run Code Online (Sandbox Code Playgroud)

Cmd + Shift + d
Run Code Online (Sandbox Code Playgroud)

但是,如何才能消除这种分裂呢?

在标准终端中,Cmd + d可以使用撤消操作Cmd + Shift + d,但在iTerm中,它用于水平拆分。

macos iterm2

3
推荐指数
1
解决办法
732
查看次数