问题列表 - 第30269页

从一个字符串中解析一个数字,其中包含非数字

我正在研究.NET项目,我试图只解析字符串中的数值.例如,

string s = "12ACD";
int t = someparefun(s); 
print(t) //t should be 12
Run Code Online (Sandbox Code Playgroud)

有几个假设

  1. 字符串模式始终是数字后跟字符.
  2. 数字部分始终为一位或两位数值.

是否有任何C#预定义函数来解析字符串中的数值?

c#

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

javascript是否具有最大运行时间?

我在javascript中运行一个循环,大约需要一分钟才能完成.当我单击应该激活循环的链接时,页面不会加载任何内容,但是当我对循环进行注释时,print语句会起作用.javascript是否只知道这个过程需要一段时间而不是这样做,如果确实存在,那么无论如何都要让它不这样做?谢谢!PS这里是代码(脚本数组超过60000个条目):

function magic(charnumber) {
    var count = 1;
    alert(charnumber);
    var output = "";
    for (count; count < scriptAr.length; count += 4) {
        if (scriptAr[count] < charnumber and sriptAr[count + 1] > charnumber) {
            output = output + scriptAr[count + 2] + '\n';
        }
    }
    alert(charnumber);
}
Run Code Online (Sandbox Code Playgroud)

javascript

0
推荐指数
1
解决办法
183
查看次数

IPhone SDK - 如何序列化ABRecord?

我是iPhone开发的新手,你能建议我如何序列化AdressBook记录吗?
我已经阅读了stackoverflow - 如何在iPhone sdk中序列化一个简单的对象,但我仍有疑问:我应该扩展ABRecordRef吗?可能吗?或者我应该实现自己的类NSObject?

(类似的问题是在Mac论坛上,没有回答)

谢谢!

iphone cocoa serialization cocoa-touch addressbook

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

How to create a byte[] of unknown size in C#?

I'm trying to create a byte[] given some unknown amount of bytes. Here's an example:

ArrayList al = new ArrayList();
al.Add(0xCA);
al.Add(0x04);
byte[] test = (byte[])al.ToArray(typeof(byte));
Run Code Online (Sandbox Code Playgroud)

I'm receiving an error that one or more of the values in the array cannot be converted to a byte. What am I doing wrong here?

Thanks

c#

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

How can you reserve a name for an application?

我的小型创业公司计划在9月开始开发Android应用程序.我的CEO想要事先注册应用程序的名称.有可能这样做吗?

android

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

哪个学校的报告功能失败更好

通常你有一个函数,对于给定的参数,它不能生成有效的结果,或者它不能执行某些任务.除了在C/C++世界中不常用的例外之外,基本上有两个学校报告无效结果.

第一种方法将有效返回与不属于函数的codomain的值(通常为-1)混合并指示错误

int foo(int arg) {
    if (everything fine)
        return some_value;
    return -1; //on failure
}
Run Code Online (Sandbox Code Playgroud)

第二种方法是返回函数状态并将结果传递给引用

bool foo(int arg, int & result) {
     if (everything fine) {
         result = some_value;
         return true;
     }
     return false;  //on failure
}
Run Code Online (Sandbox Code Playgroud)

您更喜欢哪种方式?为什么?第二种方法中的附加参数是否会带来显着的性能开销?

c c++ return return-value

8
推荐指数
3
解决办法
1014
查看次数

为什么var和*to var在这个const_cast示例中给出了diff值

检查此示例是否为const的const_cast.我正在使用VC++ 2008来编译它.

#include <iostream>
using namespace std;

void main() {
const int x=0;
int y=90;
int *p = const_cast<int *> (&x);
*p=y;

cout<<" value of x: "<<x<<" addr of x "<<&x<<endl
    <<" and *p : "<<*p<<" and addr p "<<p<<endl;

}
Run Code Online (Sandbox Code Playgroud)

================

输出是

value of x: 0 addr of x 0012FF60
 and *p : 90 and addr p 0012FF60
Run Code Online (Sandbox Code Playgroud)

c++

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

309
推荐指数
4
解决办法
36万
查看次数

室内定制地图应用

我目前正处于Android项目的研究阶段.我有兴趣开发室内自定义地图应用程序.我目前面临的问题有两个:

  1. 我无法使用GPS,因为它无法在建筑物或商场等室内环境中使用
  2. I can't use Google Maps API as I need to show my location on a indoor custom map(like a floor-plan of a building). I'm assuming here that I have the custom map of the building or mall.

Now my goal is to find location of the Android phone using some methods and display it on the custom map.To find the location I have following options,

  1. Use of Bluetooth dongles or transmitters, I am assuming that Bluetooth dongles or …

android google-maps dictionary bluetooth wifi

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

确保客户端上的文件状态与NFS服务器同步

我正在尝试找到适当的方法来处理NFS客户端上的陈旧数据.考虑以下场景:

  • 两台服务器使用多个文件挂载相同的NFS共享存储
  • 1服务器上的客户端应用程序删除一些文件
  • 2服务器上的客户端应用程序尝试访问已删除的文件,但失败的是:过时的NFS文件句柄(没什么奇怪的,预计会出错)

(另外,可能有用的是要知道,出于性能原因,两个服务器上的缓存安装选项都相当高).

我想要了解的是:

  • 有可靠的方法来检查,该文件是否存在?在上面给出的场景中,文件上的lstat返回成功,只有在尝试移动文件后应用程序才会失败.
  • 如何手动将客户端上的目录内容与服务器同步?
  • 有关如何在NFS的情况下编写可靠的文件管理代码的一般建议?

谢谢.

c linux nfs

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