小编Shr*_*ree的帖子

容器类中的大量变量

有没有人对如何在C#中设计容器类有任何建议,其中包含超过30个变量?

我把它写成一组变量,因为有一些不同的类型,例如字符串或DateTime,但是我认为将它们全部存放在对象字典中并将它们的属性名称作为键可能会更好?

干杯,艾德

c#

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

在下划线之前匹配所有内容的正则表达式

我有很多关于RegEx的知识,但我对这个问题感到困惑.我需要匹配的一切正则表达式之前的最后底线,但只有当下划线后的文字是"自我","盟友"或"敌人".

所以,如果我有这样的输入字符串:

"hero_anti_infantry_melee_2_self"
"anti_infantry_ranged_2_ally"
"suppression_aoe_enemy"
"reinforce_btn_down"
"inset_energy"
"suppressed"
Run Code Online (Sandbox Code Playgroud)

我希望他们输出为:

"hero_anti_infantry_melee_2"
"anti_infantry_ranged_2"
"suppression_aoe"
//No Match (not match because it isn't enemy, ally, or self after the underscore)
//No Match
//No Match (not underscores or enemy/ally/self
Run Code Online (Sandbox Code Playgroud)

这是使用C#RegEx引擎,它可以使用任何必要的RegEx选项.

.net c# regex c#-4.0

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

PHP正则表达式,替换所有垃圾符号

对于这样做,我无法理解一个可靠的RegEx,在这个RegEx魔术中仍然是非常新的.我取得了一些有限的成功,但我觉得有一种更简单,更有效的方式.

我想净化一串所有非字母数字字符,并将所有这些无效子集转换为单个下划线,但在边缘处修剪它们.例如,字符串<<+?This?//String_..!应转换为This_String

有关在一个RegEx中完成此操作的任何想法吗?我用普通的str_replace做了它,然后将多次下划线重新排列,然后从边缘修剪掉最后一个下划线,但它看起来有点矫枉过正,就像RegEx一次可以做的那样.这里有最大的速度/效率,即使它是我正在处理的毫秒.

php regex string

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

在JQuery中通过复选框显示隐藏div

JQuery的:

$('#chkCaption').live("click", function() {
    if ($('#chkCaption').attr("checked")) {
        $('#divCaption').show();
    }
    else {
        $('#divCaption').hide();
    }
});
Run Code Online (Sandbox Code Playgroud)

但它不起作用.帮助找到我的错误或建议的方式.谢谢.

jquery

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

VS 2012和Windows 2008 Server Enterprise

当我尝试在Windows Server 2008 Enterprise上安装Visual Studio 2012时,我收到安装程序的错误消息.

  You must upgrade or update Operating Systems to the latest Service Pack using Window Update to meet the requirement before installing this products.
  For Windows 8, this product is not compatible with pre-released versions of Windows 8. Please upgrade to latest release version of Windows 8.
  This computer does not meet the setup requirements. For more information, see the readme.
  http://go.microsoft.com/fwlink/?LinkId=255962
Run Code Online (Sandbox Code Playgroud)

我已在操作系统上安装了每个更新.我该怎么做才能安装VS2012 Ultimate?

windows-server-2008 visual-studio

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

在asp.net中使用内联css是不好的做法吗?

我是css的新手.我的项目是Layout Manager.我大部分时间都在使用inline css.当我向项目负责人展示我的项目时,他说要减少内联css.

内联css对项目真的不好吗?请帮助清除我的愿景.

css asp.net

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

Tomcat maxthreads,我做错了什么?

在catalina.out中,我看到此消息出现在日志中:

Maximum number of threads (200) created for connector with address null and port 80

这是否意味着一个过程正在占用某些东西,还是我需要增加线程大小?

重新启动tomcat后,我收到了像这条消息的垃圾邮件:
"SEVERE: The web application [/MyServlet] is still processing a request that has yet to finish. This is very likely to create a memory leak. You can control the time allowed for requests to finish by using the unloadDelay attribute of the standard Context implementation."

有办法解决我的情况吗?

java tomcat

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

CQ中的用户代码未对SQLException进行处理

我试着检查用户是否存在.我尝试:

public static bool GetUser(string tblName, string UserName,string Password,string Usertype)
        {
            try
            {

                using (SqlConnection con = Connection.GetConnection())
                {
                    using (SqlCommand cmd = con.CreateCommand())
                    {
                       cmd.CommandText = "select count(UserName) from " + tblName + " where Password=" + Password + " and usertype=" + Usertype + " and username="+ UserName + "";
                        object obj = cmd.ExecuteScalar();
                        if (obj != null)
                            return true;
                        return false;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }
Run Code Online (Sandbox Code Playgroud)

当我调用此方法时出现以下错误.
我的错误
连接成功建立,我这样称呼这个方法.

bool Check = …
Run Code Online (Sandbox Code Playgroud)

c# sql asp.net sql-server-2005

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

无法生成随机数Visual C#

我正在尝试将Rock Paper Scissors游戏作为我的第一个'项目',所以我需要计算机从1-3生成一个随机数来表示他们的回合.

我一直在尝试这段代码,但我无法弄清楚为什么它不起作用:

Random rnd = new Random();
int pchand= rnd.Next(1, 4); 
Run Code Online (Sandbox Code Playgroud)

在rnd下面有一条红色的波浪线,上面写着:

A field initializer cannot reference the non-static field, method, or property FileName.Form1.rnd
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助!

c#

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

如何在Android中实现Telenor easypay API

我正在实现telenor easypay API,其中包含两个Web服务,第一个是我发布商店ID以及其他信息,这些信息可以使我成功使用Auth_token和postbackurl进行响应。当我将auth令牌和发布URL发布到下一个Web服务URL时,https://easypaystg.easypaisa.com.pk/easypay/Confirm.jsf它将我重定向到easypaisa结帐屏幕,在Easypay结帐屏幕上显示以下错误。

请点击下面的链接查看错误截图

我的代码:

private class PostTask extends AsyncTask < String, String, String > {
 @Override
 protected void onPreExecute() {
  super.onPreExecute();
  mBT.setEnabled(false);
 }

 @Override
 protected String doInBackground(String...data) {

  OkHttpClient client; // = new OkHttpClient();
  client = getUnsafeOkHttpClient();
  client.setHostnameVerifier(new HostnameVerifier() {
   @Override
   public boolean verify(String hostname, SSLSession session) {
    return true;
   }
  });

  MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
  RequestBody body = RequestBody.create(mediaType, "amount=10&orderRefNum=110&storeId=xxxx&postBackURL=https://www.jeevaysehat.com/");
  Request request = new Request.Builder()
   .url("https://easypaystg.easypaisa.com.pk/easypay/Index.jsf")
   .post(body)
   .addHeader("content-type", "application/x-www-form-urlencoded")
   .addHeader("cache-control", "no-cache")
   .build();
  Response response = …
Run Code Online (Sandbox Code Playgroud)

android

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

C#用分号分隔的用户输入

您好,您可以建议一个简短的方法,如何用分号分隔用户输入,并将其存储到数组中.

用户输入单词时的行应该如下所示......

First;Second;Third;Forth
Run Code Online (Sandbox Code Playgroud)

c# arrays

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