我正在查看.NET Nullable<T>类的以下代码:http: //referencesource.microsoft.com/#mscorlib/system/nullable.cs,ffebe438fd9cbf0e
我想知道,以下用途的行为是什么:
int? x = null;
显然,x.hasValue()返回false,但是我看到在构造函数中,hasValue属性总是设置为true.
那我错过了什么?
我使用以下代码.我想导航到一个网页,然后单击C#Web浏览器控件中的一个按钮.但是,即使在我可以导航到网页之前,也会调用click,从而导致出现null异常.
webBrowser1.Navigate("www.remaxit.com/members"); // way before this
deleted = true;
HtmlDocument doc = this.webBrowser1.Document;
doc.GetElementById("AddUser").InvokeMember("CLICK"); //This executes
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激.
如您所见,我有一个带有子组件的父表单组件。{{myFormFather.value}} 显示我的nickName价值和name价值,但不显示age价值。{{myFormFather.status}} 它不识别组件子级。就像我的孩子是一个幻影,为什么?
我的-form-father.html
<form [formGroup]="myFormFather" (ngSubmit)="onSubmit()">
<input formControlName="nickName">
<input formControlName="name">
<my-form-child
[age]="myFormFather">
</my-form-child>
<button type="submit"
[disabled]="myFormFather.invalid">Save
</button>
</form>
Run Code Online (Sandbox Code Playgroud)
my-form-father.ts
myFormFather = new FormGroup({
nickName: new FormControl(),
name: new FormControl()
});
constructor(private fb:FormBuilder) {}
ngOnInit() {this.createForm()}
createForm() {
this.myFormFather = this.fb.group({
nickName: ['', [Validators.required],
name: ['', [Validators.required]
});
}
Run Code Online (Sandbox Code Playgroud)
my-form-child.html
<div [formGroup]="ageForm">
<input formControlName="age">
</div>
Run Code Online (Sandbox Code Playgroud)
my-form-child.ts
@Input() ageForm = new FormGroup({
age: new FormControl()
});
constructor(private fb:FormBuilder) {}
ngOnInit() {this.createForm()}
createForm() {
this.ageForm = …Run Code Online (Sandbox Code Playgroud) 我们目前正在使用LINQ来生成SQL查询,内部有一点魔力来处理特定于案例的查询.
到目前为止,它运作良好; 非常快,几乎没有任何问题.我们最近在从数据库查询大量数据时遇到了效率问题.
我们构造查询如下:
var someIntList = new List<int> { 1,2,3,4,5 };
var query = dtx.Query.Containers.Where(c => c.ContainerID.IsIn(someIntList));
Run Code Online (Sandbox Code Playgroud)
要么
var someStringList = new List<int> {"a", "b", "c" };
query = dtx.Query.Containers.Where(c => c.BuildingName.IsIn(someStringList));
Run Code Online (Sandbox Code Playgroud)
哪个会产生(以及一堆与此无关的其他东西):
SELECT * FROM Container WHERE ContainerID IN (1,2,3,4,5)
Run Code Online (Sandbox Code Playgroud)
和
SELECT * FROM Container WHERE BuildingName IN ('a','b','c')
Run Code Online (Sandbox Code Playgroud)
现在在这种特殊情况下,我们需要返回50,000行..这是通过5个单独的查询生成的,分割负载.数据库返回相当快(几秒钟内),但生成查询需要很长时间.
这是调用生成此特定查询的最后一个函数:
private static string GetSafeValueForItem(object item)
{
if (item == null)
return "NULL";
if (item is bool)
return ((bool)item ? "1" : "0");
if (item is …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的代码中启动MS NLB管理器(nlbmgr.exe),但程序说它不存在,即使它存在.我已经检查了文件权限,但我仍然可以访问,但它仍然无效.
这是我正在使用的代码:
if (File.Exists(@"C:\Windows\system32\nlbmgr.exe"))
{
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = @"C:\Windows\system32\nlbmgr.exe";
info.UseShellExecute = true;
info.CreateNoWindow = true;
info.WindowStyle = ProcessWindowStyle.Maximized;
info.RedirectStandardInput = false;
info.RedirectStandardOutput = false;
info.RedirectStandardError = false;
System.Diagnostics.Process p = System.Diagnostics.Process.Start(info);
}
Run Code Online (Sandbox Code Playgroud)
如果我将路径复制粘贴到命令提示符或开始 - >运行,它可以正常工作.
我看到其他帖子提到sysnative文件夹,但我的系统上不存在.
谢谢您的帮助.
我围绕着这个:
> .packages()
> (.packages())
[1] "stats" "graphics" "grDevices" "utils" "datasets" "methods" "base"
Run Code Online (Sandbox Code Playgroud)
第一个命令怎么可能没有输出,第二个命令有效?我想这是R的另一种语法问题.
我得到null异常.虽然我直接超过这个页面.我想处理null异常
C#
string json = "";
if (Request.QueryString["data"] !="")
{
json = Request.QueryString["data"];
var req = JsonConvert.DeserializeObject<Request>(json);//getting error in this line
string requestid = req.requestId;
SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["MYSTRING"].ConnectionString);
SqlCommand cmd = new SqlCommand();
connection.Open();
}
Run Code Online (Sandbox Code Playgroud)
错误
值不能为空.参数名称:value
我从sql server获取季度记录.这些记录就像每年每个季度的总借记和贷记.在我的SQL查询中,我已经制作了季度,并且年份是动态的,您可以在代码中看到.
public List<QuarterlyExpenseList> GetExpenseDataQuarterly(string Id, string Year)
{
string SQL = "select aspnetusers.username, SUM(case when Expense.Type='credit' and (Expense.Date>='@year-01-01' and Expense.Date<='@year-03-31') then Expense.Amount else 0 end) as QuarterOneCredits,";
SQL += " SUM(case when Expense.Type='credit' and (Expense.Date>='@year-04-01' and Expense.Date<='@year-06-30') then Expense.Amount else 0 end) as QuarterTwoCredits,";
SQL += " SUM(case when Expense.Type='credit' and (Expense.Date>='@year-07-01' and Expense.Date<='@year-09-30') then Expense.Amount else 0 end) as QuarterThreeCredits,";
SQL += " SUM(case when Expense.Type='credit' and (Expense.Date>='@year-10-01' and Expense.Date<='@year-12-31') then Expense.Amount else 0 end) as QuarterFourCredits,";
SQL …Run Code Online (Sandbox Code Playgroud) 下面是我的配偶副本到客户端(两者都是相同的对象类型).然后将配偶设为null.
client = spouse; // Copying data
spouse = null;
Run Code Online (Sandbox Code Playgroud)
然后我暂停(在另一条线上使用断点)并检查客户端和配偶的内存.配偶是空的,但客户不是.
客户端不应该为null,因为它的内存是浅拷贝的结果吗?
干杯
// subject
class SafeMode
{
private bool m_enable = false;
public bool Disable()
{
return m_enable;
}
public delegate void NotifyObserversHandler(bool _status);
public event NotifyObserversHandler DiableCommands;
public void Notify()
{
DiableCommands(m_enable);
}
}
public interface ICommand
{
void Execute(User i_User, string i_ButtonText, List<Photo> o_Photos);
void DiableFunctionality();
}
// my only observer
public class MostPopularPic : ICommand
{
public void DisableFunctionality()
{
m_enable = false;
}
}
// at other form class that's where i attach my observer to the delegate …Run Code Online (Sandbox Code Playgroud) c# ×8
sql ×2
angular ×1
asp.net ×1
delegates ×1
javascript ×1
mysql ×1
null ×1
nullable ×1
optimization ×1
r ×1
shallow-copy ×1
typescript ×1