小编Joh*_*sch的帖子

简单的减法和演员问题

为什么这个简单的减法不起作用?

int MyPageNumber = Convert.ToInt32(cboPageNumber.SelectedItem);
MyPageNumber += (MyPageNumber - 1); //does not work
int MyNewPageNumber = MyPageNumber - 1; /works
Run Code Online (Sandbox Code Playgroud)

我也希望有人可以告诉我为什么这给了我一条"红线"因为无法进行演员表演:

short MyPageNumber = Convert.ToInt16(cboPageNumber.SelectedItem);
MyPageNumber += MyPageNumber - ((short) 1); //does not work says can't cast
Run Code Online (Sandbox Code Playgroud)

我不明白的是什么?是+在示例中将其转换为字符串吗?

谢谢.

c# casting

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

.NET配置部分设计器 - 我的收藏在哪里?

我正在使用.NET 的Configuration Section Designer来构建一个简单的ConfigurationElementCollection.它似乎一切都建立得很好,因为子元素与智能感知可见的是自动生成的代码.

不幸的是,即使我在配置部分中向集合添加了元素,它们在运行时也不存在; 它显示集合的Length属性为0 - 即使集合是空的,正如您在我的示例XML中看到的,我已经明确地将它们放在那里:

配置示例

<logParserSettings xmlns="LogParser">
  <domainControllers>
    <domainController ID="0" name="Local" serverType="Local" enabled="true"/>
    <domainController ID="1" name="DC1" serverType="WindowsServer2003" enabled="false" />
    <domainController ID="2" name="DC2" serverType="WindowsServer2008" enabled="false" />
  </domainControllers>
</logParserSettings>
Run Code Online (Sandbox Code Playgroud)

  • 在设计师中,我所拥有的只是你在这里看到的,a ConfigurationSection,a ConfigurationElementCollection和a ConfigurationElement- 没有其他配置元素/部分/组
  • 我不是在运行时添加或删除任何内容
  • 我已尝试生成和不生成Singleton属性,但单例实例和设置类的实例似乎都不起作用
  • 对于ID属性,该Is Key属性设置为true,所有其他属性都标记为trueIs Required

有没有人碰到这个?如果是这样,我必须做出哪些改变才能使其按预期工作?

.net configuration app-config designer config-designer-csd

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

如何遍历包含从MySQL返回的数据的PHP数组?

好吧,我有一张桌子,里面有几个字段.其中一个领域是username.有很多次它username是相同的,例如:

    • 用户名:bob
    • 密码:鲍勃
    • 报告:1
    • 用户名:bob
    • 密码:鲍勃
    • 报告:2

我做了一个SQL语句select * where username='bob';但是当我执行以下PHP函数时,它只返回最后一个结果:

$thisrow = mysql_fetch_row($result);
Run Code Online (Sandbox Code Playgroud)

我需要从每一行得到每一个领域.我应该怎么做呢?

$mainsection="auth"; //The name of the table
$query1="select * from auth where username='$user'"; 
$result = mysql_db_query($dbname, $query1) or die("Failed Query of " . $query1);  //do the query
$thisrow=mysql_fetch_row($result);
echo "Study: " . $thisrow[1] . " - " . $thisrow[5];
Run Code Online (Sandbox Code Playgroud)

对不起这个愚蠢的问题.我似乎无法让while不止一个领域的循环为我的生活而工作.

php sql loops

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

HttpContext.Current表示用户的当前上下文...当前上下文的含义是什么?

HttpContext.Current返回IPrincipal表示当前用户的安全上下文的对象.我理解主体对象将用户的身份与其他信息(如角色,权限等)相结合.

但为什么我们说它代表用户的当前背景?为什么不说它代表用户?我们使用术语" 当前语境"是否有特殊原因?

c# asp.net security

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

转换为双转义字符串

在C#中,我有一个需要转换为双重转义的文件名(因为我将此字符串提供给正则表达式).

换句话说,如果我有:

FileInfo file = new FileInfo(@"c:\windows\foo.txt");
string fileName = file.FullName;
Run Code Online (Sandbox Code Playgroud)

fileName 是: c:\\\\windows\\\\foo.txt

但我需要将其转换为在fileName中包含两个文字反斜杠\\的序列.fileName需要是@"c:\\\\windows\\\\foo.txt",或"c:\\\\\\\\windows\\\\\\\\foo.txt".有一种简单的方法可以进行此转换吗?

c# string

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

ASP.NET MVC:调用Html.RenderPartial()时出现堆栈溢出错误

我有一个名为ActivationController的Controller,带有一个LogOn动作,它呈现视图LogOn.aspx.LogOn.aspx呈现一个名为LogOn.ascx的局部视图:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    LogOn
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>Account Activation Step 1 - Log On</h2>

    <p>
        <%Html.RenderPartial("LogOn")<;%>
    </p>

</asp:Content>
Run Code Online (Sandbox Code Playgroud)

在调用动作时,我遇到了"Stack Overflow"异常:

System.Web.Mvc.dll中发生了未处理的"System.StackOverflowException"类型异常

任何线索?

提前致谢!

asp.net-mvc view partial

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

浮点数学不正确?

这是一个让我在过去几个小时里完全感到困惑的问题......

我的程序中有一个硬编码的等式:

double s2;

s2 = -(0*13)/84+6/42-0/84+24/12+(6*13)/42;
Run Code Online (Sandbox Code Playgroud)

每次我运行该程序时,计算机会吐出3作为答案,但是手动进行数学计算,我得到4.更进一步,在将方程式输入Matlab之后,我也得到了答案4.这里有什么进展?

我唯一能想到的就是这里出错了就是圆满错误.然而,最多有5个舍入误差,再加上使用双精度数学,我的最大误差将非常小,所以我怀疑这是问题所在.

有谁能提供任何解决方案?

提前致谢,

-Faken

c++ floating-point

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

撕掉我的头发 - ASP.Net AJAX AutoComplete无法正常工作

希望有人能帮忙解决这个问题.我一直在网络上,并通过这个网站寻找答案,但仍然无法使Autocomplete AJAX控件工作.我试图将它包含在一个现有的网站中,直接将其剥离回一个非常基本的形式,但它仍然无法运行.我使用页面方法而不是本地Web服务有更多的运气,所以这是我的代码

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="droptest.aspx.cs" Inherits="droptest" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>  
    <form id="form1" runat="server">    
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" runat="server">
        </asp:ScriptManager>
        <cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" 
            MinimumPrefixLength="1" ServiceMethod="getResults" 
            TargetControlID="TextBox1">
        </cc1:AutoCompleteExtender>
    </form>
</body>
</html>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Script.Services;
using System.Web.Services;

public partial class droptest : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e) …
Run Code Online (Sandbox Code Playgroud)

c# autocomplete asp.net-ajax

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

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

如何使用jQuery为文本颜色设置动画?

$(document).ready(function(){
    $('a.nav_menu')
        .css( {backgroundPosition: "0 0"} )
        .mouseover(function(){
            $(this).animate({
            backgroundPosition:"(-650px 0)",
            'color': '#000000'
        }, {duration:700})
        })
        .mouseout(function(){
            $(this).animate({backgroundPosition:"(0px 0)"}, {duration:900, complete:function(){
                $(this).css({backgroundPosition: "0 0"})
            }})
        })
});
Run Code Online (Sandbox Code Playgroud)

这有什么问题?文字颜色不会改变.

jquery jquery-animate

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