小编Son*_*nül的帖子

等待内部方法直到捕获事件

我在C#中遇到了这个问题.我做了一个方法,从一个dll调用一个函数,它被称为Phone.GetLampMode(); Now Phone.GetLampMode并不返回任何东西.在' onGetLampModeResponse'事件中返回数据.有没有办法可以在我的方法中等待,直到我从onGetLampModeResponse事件中获取数据?

public bool checkLamp(int iLamp)
{
    Phone.ButtonIDConstants btn = new Phone.ButtonIDConstants();
    btn = Phone.ButtonIDConstants.BUTTON_1;
    btn += iLamp;
    Phone.GetLampMode(btn, null);

    return true;
}

private void Phone_OnGetLampModeResponse(object sender, Phone.GetLampModeResponseArgs e)
{
    var test = e.getLampModeList[0].getLampMode.ToString();    
}
Run Code Online (Sandbox Code Playgroud)

c# events wait

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

Lucene的索引和搜索日期

我试着用DateTools.dateToString()方法索引日期.它适用于索引和搜索.

但是我已经索引的数据有一些引用,它已经将Date作为新索引编入索引Date().getTime().

所以我的问题是如何RangeSearch Query对这些数据执行...

任何解决方案???

提前致谢.

java lucene

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

如何在c#中将double值转换为DateTime?

我有值40880.051388并将其存储为双,如果我打开Excel并粘贴到单元格并将以下自定义格式" m/d/yyyy h:mm"应用于该单元格,我得到"12/3/2011 1:14"

如何在C#中进行解析/转换?我不知道某个检查点的值是毫秒,如纪元时间,还是该值是以某种特定的准备格式,但是excel如何得出这个特定值?可以在C#中完成吗?

我尝试过在Visual Studio中使用TimeSpan,DateTime和其他类似的东西,但我没有到达任何地方.

c# excel datetime timespan converter

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

为什么"K".Length给我错误的结果?

我看到这个奇怪的问题,在网上任何地方都找不到类似的东西:

int l = "K".Length;    //This actually returns 2 !!! The 'Autos' window in
                       //the debugger also shows "K".Length as 2.

string s = "K";
l = s.Length;          //Whereas this returns 1 as expected
Run Code Online (Sandbox Code Playgroud)

我在各种C#项目中尝试了这一点,甚至要求另一位开发人员确认在不同机器上的不同项目中的行为是相同的.

我在VB.NET中尝试了同样的方法:

Dim l As Integer = "K".Length    'This returns 1 correctly
Run Code Online (Sandbox Code Playgroud)

我失去了吗?

c# string string-length

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

是否有一个Visual Studio扩展,使intellisense吸收更少?

好吧,简而言之,我想让intellisense向我展示弹出窗口中的所有可能参数,而不仅仅是其中一个,我必须像疯了一样上下旋转(微软在过去10年中如何解决这个问题?)

我知道resharper有它,但resharper很贵,我只想那样.

简而言之,我想要一些让intellisense看起来像那样的东西(来自resharper): 在此输入图像描述

而不是当前看起来像这样的垃圾: 在此输入图像描述

开始spining baby你有19个选择保持打起来并希望U WONT MISS它!:d

我希望你能简单地理解这个想法:10年前让intellisense像每10年前的Java IDE一样工作.

c# intellisense visual-studio-2012

10
推荐指数
0
解决办法
685
查看次数

将Combobox添加到DataGridView标头

当我运行我的代码时,dataGridView TopLeftHeaderCell也有一个组合框.我怎么能改变呢?

这是我的代码:

public void AddHeaders(DataGridView dataGridView)
{

        for (int i = 0; i < 4; i++)
        {
            // Create a ComboBox which will be host a column's cell
            ComboBox comboBoxHeaderCell = new ComboBox();
            comboBoxHeaderCell.DropDownStyle = ComboBoxStyle.DropDownList;
            comboBoxHeaderCell.Visible = true;

            foreach (KeyValuePair<string, string> label in _labels)
            {
                comboBoxHeaderCell.Items.Add(label.Key);
            }

            // Add the ComboBox to the header cell of the column
            dataGridView.Controls.Add(comboBoxHeaderCell);
            comboBoxHeaderCell.Location = dataGridView.GetCellDisplayRectangle(i, -1, true).Location;
            comboBoxHeaderCell.Size = dataGridView.Columns[0].HeaderCell.Size;
            comboBoxHeaderCell.Text = _labels[i].Key;

        }
}
Run Code Online (Sandbox Code Playgroud)

谢谢

c# winforms

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

TryParseExact返回false,但我不知道为什么

TryParseExact下面的代码块中的方法 返回true.
我想知道为什么.
我认为这个日期"2013.03.12"是无效的,因为它没有用斜线分隔,而是用点分隔.

在我更改了CultureInfo "de-De"to之后"en-US",该方法返回false.这可能是一个提示,但我仍然不知道为什么会发生这种情况.

var format = new string[] { "yyyy/MM/dd" };
var parsed = new DateTime();
var result = DateTime.TryParseExact("2013.03.12", format, 
             new CultureInfo("de-DE"), DateTimeStyles.None, out parsed);
Run Code Online (Sandbox Code Playgroud)

.net c# string datetime datetime-parsing

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

将布尔值转换为会话变量

关于如何将代码中的"可食用"转换为会话以在不同页面上显示为标签的任何想法.将非常感谢帮助.

标签将显示消息,如是可以吃

代码吼叫

public int totalCalories()
        {
            return grams * calsPerGram;
        }
        public string getFruitInfo()
        {
            string s;
            if (edible == true)
            {
                s = fName + " is good and it has " + totalCalories() +
 "calories";
            }
            else
            {
                s = "Hands off! Not edible";
                //edible = Sesion ["ediblesesion"] as bool;
                // Session ["ediblesession"] = edible;
            }
            return s;
        }
    }
Run Code Online (Sandbox Code Playgroud)

c# asp.net boolean session-variables visual-studio-2010

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

Newtonsoft JSON.net反序列化错误,其中JSON中的字段更改顺序

这是从Android设备获取请求的WCF服务.相同的请求适用于Lollipop设备,而不是来自软糖设备,因为软糖在创建时以不同方式排列JSON.

例外:

反序列化对象时出现意外的标记:String.路径'SearchFilters.config.$ type',第1行,第212位.

不工作的Json:

{
    "DeviceType": 2,
    "SearchFilters": {
        "config": {
            "$values": [
                {
                    "Collection": {
                        "DeviceType": 2
                    },
                    "Category": ""
                }
            ],
            "$type": "System.Collections.Generic.List`1[[Yoosh.SharedClasses.YooshConfig, YooshSharedClassesDll]], mscorlib"
        }
    },
    "RequestingUserId": "66666666-6666-6666-6666-666666666666",
    "APIKey": "xxx"
}
Run Code Online (Sandbox Code Playgroud)

工作Json:

{
    "APIKey": "xxx",
    "DeviceType": 2,
    "RequestingUserId": "66666666-6666-6666-6666-666666666666",
    "SearchFilters": {
        "config": {
            "$type": "System.Collections.Generic.List`1[[Yoosh.SharedClasses.YooshConfig, YooshSharedClassesDll]], mscorlib",
            "$values": [
                {
                    "Category": "",
                    "Collection": {
                        "DeviceType": 2
                    }
                }
            ]
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

有些字段的顺序不同.这是唯一的区别.

C#类:

public class QueryParameters 
{
    BaseParameters m_baseParameters;
    Guid m_gRequestingUserId;
    Dictionary<string, object> m_SearchFilters;

    [DataMember] …
Run Code Online (Sandbox Code Playgroud)

c# json.net

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

如何断开与elasticsearch-py客户端/连接池的连接

什么是断开elasticsearch-py(python)客户端rsp的正确方法.关闭现有连接池?我在文档中找不到任何信息.

python elasticsearch pyelasticsearch

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