问题列表 - 第44881页

以下两者之间有任何区别

1)A a;
2)A a = null;

有什么区别吗?

.net c#

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

将Int转换为Guid

我必须将Convert Int32转换为Guids,这就是我想出来的.

public static class IntExtensions
{
    public static Guid ToGuid(this Int32 value)
    {
        if (value >= 0) // if value is positive
            return new Guid(string.Format("00000000-0000-0000-0000-00{0:0000000000}", value));
        else if (value > Int32.MinValue) // if value is negative
            return new Guid(string.Format("00000000-0000-0000-0000-01{0:0000000000}", Math.Abs(value)));
        else //if (value == Int32.MinValue)
            return new Guid("00000000-0000-0000-0000-012147483648");  // Because Abs(-12147483648) generates a stack overflow due to being > 12147483647 (Int32.Max)
    }
}
Run Code Online (Sandbox Code Playgroud)

但它有些丑陋.谁有更好的主意?

更新:

是的,我知道整件事情都是丑陋的,但我失去了想法.问题是.我正在获取数据并且必须将其存储到表中我无法更改.发送数据主键是Int,而我必须存储的表主键是Guid.问题是我必须了解发件人正在谈论的对象,但只能将其存储为Guid.

更新2:

好的,我知道我必须在这里提供更多信息.我是一个接收数据的Web服务,必须将数据传递给我无法控制的接口.所以我既不能模拟收到的数据,也不能模拟我必须发送数据的(接口)数据库.另外,我必须以某种方式映射这两个东西,以便我能以某种方式更新项目.

c#

37
推荐指数
3
解决办法
4万
查看次数

诺基亚Qt的基本概念是什么?

诺基亚Qt的基本概念是什么?

在进入诺基亚Qt框架之前,我想知道些什么?

任何人都可以帮助我吗?

诺基亚Qt我是新手.提前致谢.

qt nokia qt4

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

为什么我不能实现Django的忘记密码功能?

Reverse for 'django.contrib.auth.views.password_reset_confirm' with arguments '()' and keyword arguments '{'uidb36': '1', 'token': '2u6-e139d87034d52a80c572'}' not found.
Run Code Online (Sandbox Code Playgroud)

我已经正确地做了这个:

(r'^password/reset/?$',password_reset ),
(r'^password/reset/done/?$',password_reset_done ),
(r'^password/reset/confirm/?$',password_reset_confirm ),
(r'^password/reset/complete/?$',password_reset_complete),
Run Code Online (Sandbox Code Playgroud)

python django

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

Android视频作为动态壁纸

我想把视频作为动态壁纸.我正在使用媒体播放器.我可以获得SurfaceHolder,我可以将该持有者交给媒体播放器.但它不适合我,它给我以下例外

LogCat异常详细信息

ERROR/AndroidRuntime(302): java.lang.UnsupportedOperationException: Wallpapers do not support keep screen on
Run Code Online (Sandbox Code Playgroud)

如果我不给媒体播放器的持有者它的工作原理,但我只能听到音频.我看到一个应用程序VideoLiveWallpaper,它将视频设置为动态壁纸,所以它可能,我可能会遗漏一些东西.我正在粘贴代码,对此的任何帮助将不胜感激.

代码片段

public void surfaceCreated(SurfaceHolder holder) {
  // TODO Auto-generated method stub

 holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
  mp=MediaPlayer.create(getApplicationContext(), R.raw.sample);
  mp.setDisplay(holder);
  mp.start();
 }
Run Code Online (Sandbox Code Playgroud)

android live-wallpaper

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

jQuery XML解析如何获取元素属性

XML:

<item>
     <title>Some title</title>

     <description>
     <![CDATA[
      Some description text Some description text Some description text Some description text Some description text Some description text 
      Some description text Some description text Some description text Some description text Some description text Some description text 
      Some description text Some description text Some description text Some description text Some description text Some description text 
      Some description text Some description text Some description text Some description text Some description text Some description text 
     ]]>
     </description> …
Run Code Online (Sandbox Code Playgroud)

xml jquery

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

getHeight()vs getLayoutParams().height

是有什么区别getHeight()getLayoutParams().heightView?我有一个View(GoogleAdView),我想隐藏它,我设置getLayoutParams().height为零,但广告的高度(ad.getHeight())不是零.

有没有办法隐藏View它,以便它不占用布局中的空间?

我试图将其可见性设置为GONE或设置ad.getLayoutParams().height为零,但这不起作用.

height android view

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

以正确的方式设计课程

我有一些关于JavaScript的问题,我需要确定.为了帮助,我有一个简单的类定义我正在写:

var dataSource = function (src, extension) {
    return {
        exists: function () {
            // function to check if the source exists (src *should* be an object
            // and extension should be a string in the format ".property.property.theSource".
            // this function will return true if src.property.property.theSource exists)
        },
        get: function () {
            // function will return the source (ex: return src.property.property.theSource)
        }
    }   
}();
Run Code Online (Sandbox Code Playgroud)

问题:

1)在我目前对JavaScript的理解中,调用dataSource()将创建一个具有自己的exists()和get()方法副本的新对象.我对么?

2)有没有办法写这个,这样如果我创建1,000,000个dataSource对象,我只需要每个函数的一个副本?

3)我是否应该关注(2)?

javascript oop

5
推荐指数
2
解决办法
1051
查看次数

Environment.SetEnvironmentVariable需要很长时间才能在用户或计算机级别设置变量

我正在使用C#(.NET 3.5)中的Environment.SetEnvironmentVariable方法调用,如下所示:

Environment.SetEnvironmentVariable(environmentVariable,value,"Machine");

但是,在单个测试系统(运行XP和Windows 7)上,这个单个调用需要2秒多的时间.我想通了,这可能是因为:"如果目标是用户或计算机,其他应用程序由Windows WM_SETTINGCHANGE消息通知的设置操作的." 有没有办法将此通知抑制到其他应用程序,以便我的环境快速设置并返回..?

请注意,我有一个组件可以设置大约20个环境变量,如果我使用上面描述的功能,则需要大约一分钟才能完成该任务.

请建议!!

c# environment-variables

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

透明QWidget/QScrollArea背景样式设置无效

这个问题涉及到

我在这里问,因为我相信SO社区可能有办法解决这个问题.

所以我喜欢将ScrollArea的背景颜色设置为透明或自定义背景图像,因为它将包含一些横幅.我已经在Qt Creator(Designer)中运行了它!:-):

Qt Creator样本

但是当将应用程序部署到模拟器时它将无法工作,它们会保持灰色,深灰色:

仿真器样本

这是我的布局树:

布局树

这是我正在使用的样式表(附加并设置为MainWindow):

QMainWindow {
    background: transparent url(:/ui/designs/images_from_android/bg_plain_empty.png) top left;
}
QWidget#centralWidget {
    background-color: transparent;
}
QPushButton {
    color: red;
    border: 1px solid green;
}
QFrame#top_header {
    background: transparent url(:/ui/designs/images_from_android/bg_title_bar_landscape.png) top left repeat-x;
}
QWidget#top_banner_scroll1,
QWidget#top_banner_scroll2 {
    background: transparent url(:/ui/designs/images_from_android/stripe_bg.png) top left repeat-x;
}
Run Code Online (Sandbox Code Playgroud)

这非常令人费解.正如Qt Designer向我展示了合适的设计......

qt symbian

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