我已经阅读了一些SO帖子,似乎缺少最基本的操作.
public enum LoggingLevel
{
Off = 0,
Error = 1,
Warning = 2,
Info = 3,
Debug = 4,
Trace = 5
};
if (s == "LogLevel")
{
_log.LogLevel = (LoggingLevel)Convert.ToInt32("78");
_log.LogLevel = (LoggingLevel)Enum.Parse(typeof(LoggingLevel), "78");
_log.WriteDebug(_log.LogLevel.ToString());
}
Run Code Online (Sandbox Code Playgroud)
这没有例外,它很乐意存储78.有没有办法验证进入枚举的值?
从dll加载dll的最佳方法是什么?
我的问题是我无法在process_attach上加载一个dll,我无法从主程序加载dll,因为我不控制主程序源.因此我也不能调用非dllmain函数.
我希望有一个扭曲的服务(通过twistd启动),它监听指定IP地址上指定端口上的TCP/POST请求.到目前为止,我有一个扭曲的应用程序,它侦听localhost上的端口8040.它运行正常,但我希望它只收听某个IP地址,比如10.0.0.78.
怎么管理?这是我的代码片段:
application = service.Application('SMS_Inbound')
smsInbound = resource.Resource()
smsInbound.putChild('75sms_inbound',ReceiveSMS(application))
smsInboundServer = internet.TCPServer(8001, webserver.Site(smsInbound))
smsInboundServer.setName("SMS Handling")
smsInboundServer.setServiceParent(application)
Run Code Online (Sandbox Code Playgroud) 任何人都可以告诉我下面两个陈述之间的差异.
[self playButtonSound];
Run Code Online (Sandbox Code Playgroud)
和:
[self performSelector:@selector(playButtonSound)];
Run Code Online (Sandbox Code Playgroud)
我只是问,因为我有一些使用过的旧代码@selector,现在有了更多的知识,我想不出为什么我没有使用[self playButtonSound],他们似乎都像在这里写的一样.
加里
问候,我正在使用jsTree来生成我的分层数据.JsTree生成如下:
$(function() {
$("#industries").tree({
data: {
type: "json",
opts: {
url: "/Admin/GetIndustries/"
}
}
});
});
Run Code Online (Sandbox Code Playgroud)
它的工作原理和jsonresult是这样的:
[{"attributes":[],"data":{"title":"Adwokaci, Notariusze","id":"1a051101-c3fa-48f2-b2e1-c60d1b67ea22"},"children":[{"attributes":[],"data":{"title":"Kancelarie adwokackie","id":"26d6cff1-3c7f-4a2f-bf5a-422e08127b43"
Run Code Online (Sandbox Code Playgroud)
我的问题是:如何在某些隐藏字段中保存所选节点的ID?我做这样的事情:
<script type="text/javascript">
$("#industries").click(function() {
var tree = $.tree.reference("industries");
var t = $.tree.focused(); if (t.selected) t.selected; else alert("Select a node first");
alert(t.id);
});
Run Code Online (Sandbox Code Playgroud)
但它不起作用.我进入警报窗口"未定义".有人可以帮帮我吗?
编辑: 我已经更改了jstree实例,如下所示:
$(function() {
$("#industries").tree({
callback: {
onselect: function(NODE, TREE_OBJ) {
alert(NODE.id);
}
},
data: {
type: "json",
opts: {
url: "/Admin/GetIndustries/"
}
}
});
});
Run Code Online (Sandbox Code Playgroud)
我得到空洞的警觉
我的知识结束了,谷歌也搜索了答案,但没有运气:/
一周前一切都运作良好.
我对存储库进行了还原,重新创建了tableadapter等......没有任何帮助.
当我尝试保存在我的应用程序中时,此时我得到一个SystemInvalidCastException:
PersonListDataSet.cs:
partial class P_GroupTableAdapter
{
public int Update(PersonListDataSet.P_GroupDataTable dataTable, string userId)
{
this.Adapter.InsertCommand.Parameters["@userId"].Value = userId;
this.Adapter.DeleteCommand.Parameters["@userId"].Value = userId;
this.Adapter.UpdateCommand.Parameters["@userId"].Value = userId;
return this.Update(dataTable); **<-- Exception occurs here**
}
}
Run Code Online (Sandbox Code Playgroud)
一切都被困在这里,因为Guid - 我用放大镜工具检查数据表预览它真的是数据表列中的真正Guid - 无法转换为字符串??? 怎么会发生这种情况?
我今天已经为此寻找了一个芒果.这看起来很容易,但我从来没有让它工作.我想用光标填充微调器.我一直在尝试使用SimpleCursorAdapter,因为很多网站都说我会,但我从来没有让它工作.告诉我它是多么容易:)
谢谢你的时间!
我的光标
Cursor cursor = db.query(DATABASE_TABLE_Clients, new String[] {"_id", "C_Name"}, null, null, null, null, "C_Name");
Run Code Online (Sandbox Code Playgroud)
我的旋转器
(Spinner) findViewById(R.id.spnClients);
Run Code Online (Sandbox Code Playgroud)
我的守则
Cursor cursor_Names = SQLData.getClientNames();
startManagingCursor(cursor_Names);
String[] columns = new String[] { "C_Name" };
int[] to = new int[] { R.id.txt_Address };
SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_dropdown_item, cursor_Names, columns, to);
Spinner spnClients = (Spinner) findViewById(R.id.spnClients);
spnClients.setAdapter(mAdapter);
Run Code Online (Sandbox Code Playgroud) 如何删除字符串中的第一个数字?如果我将这48个数字与','(逗号)分开,请说:
8,5,8,10,15,20,27,25,60,31,25,39,25,31,26,28,80,28,27,31,27,29,26,35,8,5,8,10,15,20,27,25,60,31,25,39,25,31,26,28,80,28,27,31,27,29,26,35
Run Code Online (Sandbox Code Playgroud)
如何从字符串中删除"8"?谢谢.
我似乎无法在同一名称空间(MyProject.Util)中的另一个类中找到以下扩展方法.
using System.Collections.Specialized;
namespace MyProject.Util
{
public static class Extensions
{
public static string Get(
this NameValueCollection me,
string key,
string def
)
{
return me[key] ?? def;
}
}
}
Run Code Online (Sandbox Code Playgroud)
你可以看到它基本上是另一个版本foo[bar] ?? baz,但我仍然不明白为什么VS2008无法编译告诉我没有版本Get需要两个参数.
有任何想法吗?
什么时候应该在c#4.0中使用动态关键字?....... c#4.0中使用动态关键字解释其用法的任何好例子....