小编ahm*_*iee的帖子

获取通用列表项的计数

我有一个通用的int列表,List<int>()我想知道它的一个项目的计数.我该怎么做?

c# generics generic-list c#-4.0

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

我怎样才能继续上环

我有这个代码:

foreach(int i in Directions)
        {
            if (IsDowner(i))
            {
                while (IsDowner(i))
                {
                    continue;
                    //if (i >= Directions.Count)
                    //{
                    //    break;
                    //}
                }

                //if (i >= Directions.Count)
                //{
                //    break;
                //}

                if (IsForward(i))
                {

                        continue;
                        //if (i >= Directions.Count)
                        //{
                        //    break;
                        //}

                    //check = true;
                }

                //if (i >= Directions.Count)
                //{
                //    break;
                //}

                if (IsUpper(i))
                {
                        //if (i >= Directions.Count)
                        //{
                        //    break;
                        //}
                    num++;
                    //check = false;
                }

                //if (check)
                //{
                //    num++;
                //}
            }
        }
Run Code Online (Sandbox Code Playgroud)

但我想有continue …

c# foreach loops while-loop c#-4.0

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

在lesscss中继承,不继承子类

这是我的style.less代码:

.transition {
    -ms-transition: all 0.3s ease-in-out;
    -moz-transition: all 0.3s ease-in-out;
    -o-transition: all 0.3s ease-in-out;
    -webkit-transition: all 0.3s ease-in-out;
    transition: all 0.3s ease-in-out;
}

.shadow {
    padding: 10px 10px 10px 10px;
    margin: 10px 10px 10px 10px;
    -moz-box-shadow: 0px 0px 10px #808080;
    -o-box-shadow: 0px 0px 10px #808080;
    -webkit-box-shadow: 0px 0px 10px #808080;
    box-shadow: 0px 0px 10px #808080;
}

    .shadow:hover {
        -moz-box-shadow: 0px 0px 10px #a5a5a5;
        -o-box-shadow: 0px 0px 10px #a5a5a5;
        -webkit-box-shadow: 0px 0px 10px #a5a5a5;
        box-shadow: 0px 0px 10px …
Run Code Online (Sandbox Code Playgroud)

less

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

使用LIKE关键字在SQL中搜索数据

我有一个SQL存储过程,它根据发送数据在我的表中搜索数据.但是当我使用它时,我无法得到任何结果.这是我的C#代码帽正在使用存储过程:

List<Common.CommonPersonSerchResult> SerchResult = new List<Common.CommonPersonSerchResult>();

    public DLAdvancedSearch(Common.CommonPersonAdvancedSearch data)
    {
        //Creating Connection Started...
        SqlConnection connection = new SqlConnection("Data Source=(local);Initial Catalog=Khane;Integrated Security=True");
        //Creating Connection Finished.
        //Creating Command To Run started...
        SqlCommand command = new SqlCommand();
        command.Connection = connection;
        //Creating Command To Run Finished.
        //Setting Command Text...
        command.CommandType = CommandType.StoredProcedure;
        command.CommandText = "AdvancedSearch";
        //Setting Command Text Finished.

        //Making And Setting SQL AdvancedSearch Parametters...
        SqlParameter FirstName = new SqlParameter("FirstName", SqlDbType.NVarChar, 50);
        FirstName.Value = data.FirstName;
        command.Parameters.Add(FirstName);

        SqlParameter LastName = new SqlParameter("LastName", SqlDbType.NVarChar, 50);
        LastName.Value …
Run Code Online (Sandbox Code Playgroud)

c# sql-server sql-server-2008 sql-server-2008-r2 c#-4.0

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

如何编辑所有特殊html标签的属性(如a)

我正在尝试使用c#编辑所有特殊html标记的属性(如a).例如,我想更改此代码:

<!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>
    <title>Untitled Page</title>
</head>
<body>
    <a href="http://google.com"></a>
    <a href="http://gmail.com"></a>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

对此:

<!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>
    <title>Untitled Page</title>
</head>
<body>
    <a href="http://go.go/default.aspx?url=http://google.com">
    </a><a href="http://go.go/default.aspx?url=http://gmail.com"></a>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

这意味着我想追加hrefin 的值<a>

我尝试过LinqToXML,但它不起作用,因为HTML不是有效的XML(因为DOCTYPE标记)

这是我的代码:

XDocument xmlFile = XDocument.Load(s);

var query = from c in xmlFile.Elements("html").Elements("body").Elements("a")
            select c;

foreach (XElement book in query)
{
    string atr = book.Attribute("href").Value;
    book.Attribute("href").Value = "http://ahmadalli.somee.com/default.aspx?url=" + atr;
} …
Run Code Online (Sandbox Code Playgroud)

html c# asp.net c#-4.0

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

当调用弹出窗口的`.ShowDialog()`时,WPF应用程序关闭

首先,我想解释一下我将要做的事情:我正在开发一个学习应用程序,向学生展示一些卡片.我CardPack上课是一组卡片.

为了获得卡片包的许可,我想从用户那里获得一个ID,然后我创建了一个窗口来获取用户的RegisterKey.这是我的GetRegisterKey("CardPackName")方法:

    public static string GetRegisterKey(string name)
    {
        GetRegisterKey grk = new GetRegisterKey(name);
        grk.ShowDialog();
        return grk.Key;
    }
Run Code Online (Sandbox Code Playgroud)

grk.ShowDialog();运行后程序将退出,我不知道为什么!有人可以帮我解决这个问题吗?!?


更新

我试图GetRegisterKeyWindows_loaded事件中创建一个新实例,MainWindows并且我调用grk.ShowDialog()它并且它工作正常并且程序没有关闭.我不知道问题的根源是什么!

但我发现问题不是GetRegisterKey从那时起我会从问题中删除它的代码.

UPDATE2

我把一个断点放在return grk.Key;一行检查它是否运行但它没有运行并且程序关闭了!

c# wpf

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

在SQL中设置表行的限制

我想设置表格行的限制.我该怎么做?

例如我表中的50行.

sql sql-server sql-server-2008 sql-server-2008-r2

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

样式与文件位置捆绑在一起

我想在我的代码中捆绑三个css文件.其中一个是我的网络字体,我使用'url'.但是当我运行应用程序浏览器时找不到文件.

这是我的css文件:

@font-face {
    font-family: 'neuropol';
    src: url('../Files/Font/neuropol_x_free-webfont.eot');
    src: url('../Files/Font/neuropol_x_free-webfont.eot?#iefix') format('embedded-opentype'),
         url('../Files/Font/neuropol_x_free-webfont.woff') format('woff'),
         url('../Files/Font/neuropol_x_free-webfont.ttf') format('truetype'),
         url('../Files/Font/neuropol_x_free-webfont.svg#neuropol_x_freeregular') format('svg');
    font-weight: normal;
    font-style: normal;

}  
Run Code Online (Sandbox Code Playgroud)

这是我的捆绑代码:

bundles.Add(new StyleBundle("~/bundles/styles/base").Include("~/Content/Styles/style.css", "~/Content/Styles/normalize.css", "~/Content/Styles/webfont.css"));
Run Code Online (Sandbox Code Playgroud)

有人可以帮我解决这个问题吗?

c# asp.net asp.net-mvc bundle asp.net-mvc-4

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

Twitter Bootstrap按钮组作为文本输入插件并不是那么好用

这就是我尝试过的:

<div class="input-prepend input-append">
    <input type="text" />
        <div class="add-on btn-group" data-toggle="buttons-radio">
            <button type="button" class="btn btn-primary" dir="ltr">http://</button>
            <button type="button" class="btn btn-primary" dir="ltr">https://</button>
        </div>
</div>
Run Code Online (Sandbox Code Playgroud)

但该组按钮的padding,并margin使其难看!你可以在jsFiddle中看到它

我该如何解决?

html css html5 css3 twitter-bootstrap

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

StructureMap认为它必须注入构造函数并抛出异常

我在我的应用程序中使用了StructureMap和ASP.Net Identity.我有这条线的时候Application_Start

ControllerBuilder.Current.SetControllerFactory(new StructureMapControllerFactory());
Run Code Online (Sandbox Code Playgroud)

这是StructureMapControllerFactory:

public class StructureMapControllerFactory : DefaultControllerFactory
{
    protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
    {
        if (controllerType == null && requestContext.HttpContext.Request.Url != null)
            throw new InvalidOperationException(string.Format("Page not found: {0}",
                requestContext.HttpContext.Request.Url.AbsoluteUri.ToString(CultureInfo.InvariantCulture)));
        return ObjectFactory.GetInstance(controllerType) as Controller;
    }
}
Run Code Online (Sandbox Code Playgroud)

return ObjectFactory.GetInstance(controllerType) as Controller;抛出StructureMapConfigurationException异常说:

No default Instance is registered and cannot be automatically determined for type 'IUserStore<Person>'
Run Code Online (Sandbox Code Playgroud)

但如果我删除ControllerBuilder.Current.SetControllerFactory(new StructureMapControllerFactory());行一切正常,所以它的StructureMap的问题不是我的代码.

c# structuremap asp.net asp.net-mvc structuremap3

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