小编gun*_*171的帖子

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

如何在Visual Studio 2010 C#中获取字符串的堆栈内存地址#

我目前正在大学攻读计算机科学课程,最近我们看到了如何在调试器中使用&和*获取变量的内存地址.我的老师告诉我,本地值类型变量在堆栈中,引用类型在堆中.但他也告诉堆栈应该包含字符串在堆中的地址.

我不知道你是否明白我想说的是什么,但它应该是可能的,因为我在他给我们的笔记中看到了它.但当他试图向我们展示时,它没有用,他不知道为什么.

我想知道该怎么做但是当我尝试时总是收到此错误消息:

不能获取地址,获取大小,或声明指向托管类型('string')的指针.

&nameofstringvariable在调试器中没有引号.我想了解事情是如何运作的,我在谷歌搜索这个问题的时间,但我从来没有找到解决方案.尝试使用unsafe代码并且无法正常工作.

c# visual-studio-2010

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

操作可能会破坏StructureMap中的运行时的稳定性

我在我的本地计算机上的一个ASP.NET 4.5 MVC应用程序中收到此错误.使用ASP.NET 4.5设置其他应用程序并使用StructureMap可以正常工作. 错误信息

任何帮助/解决方案都将受到高度赞赏.导致这种情况的代码行是:

using StructureMap;
using StructureMap.Graph;

namespace Management.Web.DependencyResolution
{
    public static class IoC
    {
        public static IContainer Initialize()
        {
            ObjectFactory.Initialize(x =>
            {
                x.Scan(scan =>
                {
                    scan.TheCallingAssembly();
                    scan.WithDefaultConventions();
                    scan.Assembly("Management.Core");
                    scan.Assembly("Management.DAL");
                    scan.Assembly("Management.BusinessServices");
                    scan.Assembly("Management.Infrastructure");
                });
                x.For<INavigationService>().Use<NavigationService>();
            });
            return ObjectFactory.Container;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

c# structuremap asp.net verificationexception

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

c#Json.net DbGeography反序列化错误

我试图从数据库中获取Spartial数据,然后将其序列化(工作得很好).当我尝试反序列化该数据时,抛出JsonSerializationException.

DbGeography geoPoint = CreatePoint(40.7056308, -73.9780035);
string serializedPoint = JsonConvert.SerializeObject(geoPoint);
DbGeography resjson = JsonConvert.DeserializeObject<DbGeography>(serializedPoint);
Run Code Online (Sandbox Code Playgroud)

这是CreatePoint方法:

public static DbGeography CreatePoint(double latitude, double longitude)
{
string text = string.Format(CultureInfo.InvariantCulture.NumberFormat,
"POINT({0} {1})", longitude, latitude);
return DbGeography.PointFromText(text, 4326);
}
Run Code Online (Sandbox Code Playgroud)

我在控制台应用程序中生成了此错误.

Nuget Packages installed: 
EntityFramework 6.1.0
Newtonsoft.Json 6.0.3
Run Code Online (Sandbox Code Playgroud)

有谁知道我做错了什么?

c# entity-framework json.net

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

CSS圈子在ios上看起来是椭圆形的

我使用CSS创建了几个圆圈,我在HTML索引页面上用作文本输入.问题是当内部字体比CSS圆相对较大时,圆形变成椭圆形.它只发生在IOS上.我在Safari和Chrome上测试了这个页面,它非常好.没有Android设备进行测试.我尝试过使用meta flags和webkit属性,但没有去.

任何提示?

            input[type=text5]{
                    position: absolute;
                    left: 270px;
                    top: 340px;
                    display:block;
                    width:50px;
                    height:50px;
                    line-height:50px;
                    border: 2px solid #f5f5f5;
                    border-radius: 50%;
                    margin:0 auto;
                    color:#f5f5f5;
                    text-align:center;
                    text-decoration:none;
                    background: #464646;
                    box-shadow: 0 0 3px gray;
                    font-family:Verdana;
                    font-size:16px;
                    font-weight:bold;
                    -webkit-box-sizing:content-box;
                    -moz-box-sizing:content-box;
                    box-sizing:content-box;             
            }
Run Code Online (Sandbox Code Playgroud)

大字体: 在此输入图像描述

小字体 在此输入图像描述

html css geometry ios7

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

如何使用CellValueChanged事件检索DataGridView单元格的先前值?

我正在编写一个使用DataGridView的C#应用​​程序,我想在每次用户更改那里的数据时验证输入.

我开始使用CellValidating事件,该事件具有非常好的CancelEdit()方法,该方法将单元格返回到其先前的值.但是,每次用户离开单元格时都会触发此事件,无论它是否已更改.

CellValueChanged是否支持对先前值的取消或回滚方法?这样我仍然可以验证数据,但不会浪费时间与不需要它的单元格,但如果数据无效,则不希望牺牲恢复单元格的能力.

这是一些代码:

private void dataGrid1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
    if(dataGrid1.Columns[e.ColumnIndex].Name == "dateColumn")
    {
        String input = e.FormattedValue.ToString();

        // Split the date from MM/DD/YYYY format
        String[] temps = input.Split('/');
        try
        {
            if(temps[2].Length != 4)
                MessageBox.Show("The year entered is not the correct length.", "Invalid Year", MessageBoxButtons.OK);

            DateTime date = new DateTime(Convert.ToInt32(temps[2]), Convert.ToInt32(temps[0]), Convert.ToInt32(temps[1]));
        }
        catch (Exception ex) // If exception is thrown, date was invalid
        {
            MessageBox.Show("The date entered was invalid.", "Invalid date", MessageBoxButtons.OK);
            dataGrid1.CancelEdit(); // Set cell value back …
Run Code Online (Sandbox Code Playgroud)

c# datagridview event-handling

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

为什么隐式类型优于显式类型?

C# Coding Conventions 中,当变量的类型从赋值的右侧很明显时,为什么 Microsoft 建议使用隐式类型?

我知道没有必要声明它,因为它很明显,但为什么要提出建议?显式键入不是使代码更易于遵循吗?

var str1 = "This is clearly a string.";
Run Code Online (Sandbox Code Playgroud)

对比

string str2 = "This is clearly a string.";
Run Code Online (Sandbox Code Playgroud)

这有编译时间的好处吗?

c# implicit-typing

5
推荐指数
0
解决办法
1094
查看次数

将RTF字符串转换为XAML字符串

在C#中将RTF字符串转换为XAML字符串的最有效方法是什么?我想使用,System.Windows.Documents.XamlRtfConverter.ConvertRtfToXaml(string rtfContent)但不幸的是,这个课程是内部的.

c# xaml rtf

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

在 Windows 上显示密码文本框控件

Windows 中是否有任何 API 可以将密码文本框变成这样的:

在此处输入图片说明

这样用户就可以在按下文本框旁边的眼睛图标的同时显示密码一秒钟。您知道我可以从 WinForms 应用程序调用的任何 P/Invoke 之类的 API 存在吗?

passwords textbox winforms

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

HTML:输入框默认/计算的内容高度因浏览器而异

假设我有以下代码

.username {
  font-size: 30px;
  padding-top: 8px;
  padding-bottom: 8px;
  border: 2px solid #E0E0E0;
}
Run Code Online (Sandbox Code Playgroud)
<input class="username" type="text" />
Run Code Online (Sandbox Code Playgroud)

请参阅http://jsbin.com/qudorugoguya/1/edit?html,css,output上的现场演示

据我所知,总高度=内容高度+填充顶部+填充底部+(边框宽度x 2).

http://www.w3.org/TR/CSS21/box.html#box-dimensions

但是,如果未为height属性分配值,则计算的内容高度似乎会从浏览器更改为浏览器.好像是字体大小的结果+一些与字体大小成比例的任意数量的像素.

对于不同的浏览器,content height具有以下值:

  • Chrome 38:34px
  • Firefox 33:35px
  • IE 11:34.5px
  • IE 8:35px

注意:我从每个浏览器的内置开发人员工具中获取了值

有没有办法在不设置height属性和line-height属性的情况下从浏览器到浏览器获取一致的值?

html css forms input inputbox

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