在下面的示例中,为什么产品为空?
using System.Collections.Generic;
using System.Linq;
namespace TestEventsds343
{
public class Program
{
static void Main(string[] args)
{
Product product = Product.LoadProduct(222);
}
}
public class Product
{
public int ProductNumber { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public static Product LoadProduct(int productNumber)
{
List<Product> products = new List<Product>();
products.Add(new Product { ProductNumber = 111, Name = "Intel CPU", Description = "Newest model, very fast." });
products.Add(new Product { ProductNumber …Run Code Online (Sandbox Code Playgroud) 在下面的父类SqlStatement中,如何使Initialize() 抽象但保持Execute() 虚拟?
using System;
using System.Collections.Generic;
namespace TestSql28374
{
class Program
{
static void Main(string[] args)
{
object item = new object();
List<string> properties = new List<string>();
SqlCreateStatement sqlCreateStatement = new SqlCreateStatement(properties);
sqlCreateStatement.Execute();
SqlInsertStatement sqlInsertStatement = new SqlInsertStatement(item, properties);
sqlInsertStatement.Execute();
Console.ReadLine();
}
}
public class SqlStatement
{
protected List<string> properties;
protected object item;
protected string sql;
public SqlStatement(List<string> properties)
{
this.properties = properties;
}
protected virtual void Initialize() //should be abstract
{ } …Run Code Online (Sandbox Code Playgroud) 下面的代码是一个silverlight应用程序,但在WPF中也是如此,所以它似乎只是我在委托,事件等方面缺少的东西.
任何人都可以告诉我为什么以下代码成功执行此事件:
OnLoadingComplete(this, null);
Run Code Online (Sandbox Code Playgroud)
但从不执行此事件处理程序?
void initialDataLoader_OnLoadingComplete(object obj, DataLoaderArgs args)
Run Code Online (Sandbox Code Playgroud)
码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Controls;
using System.Diagnostics;
namespace TestEvent22928
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
DataLoader initialDataLoader = new DataLoader("initial");
initialDataLoader.RegisterText("test1", "http://test:111/testdata/test1.txt");
initialDataLoader.RegisterText("test2", "http://test:111/testdata/test2.txt");
initialDataLoader.BeginLoading();
initialDataLoader.OnLoadingComplete += new DataLoader.LoadingComplete(initialDataLoader_OnLoadingComplete);
}
void initialDataLoader_OnLoadingComplete(object obj, DataLoaderArgs args)
{
Debug.WriteLine("loading complete"); //WHY DOES EXECUTION NEVER GET HERE?
}
}
public class DataManager
{
public DataLoader CreateDataloader(string dataloaderIdCode)
{
DataLoader dataLoader = new DataLoader(dataloaderIdCode); …Run Code Online (Sandbox Code Playgroud) 我有一个silverlight应用程序,用户可以在浏览器外安装.
当右键单击,并期待在更新面板,它被设置为"检查更新,并让我选择是否下载并安装:
替代文字http://www.deviantsart.com/upload/uhjdal.png
然而,用下面的代码,我的应用程序检测并下载新版本的自动,和新版本可于下次启动应用程序,无需任何用户互动:
App.xaml.cs:
private void Application_Startup(object sender, StartupEventArgs e)
{
this.RootVisual = new BaseApp();
if (Application.Current.IsRunningOutOfBrowser)
{
Application.Current.CheckAndDownloadUpdateAsync();
Application.Current.CheckAndDownloadUpdateCompleted += new CheckAndDownloadUpdateCompletedEventHandler(Current_CheckAndDownloadUpdateCompleted);
}
}
void Current_CheckAndDownloadUpdateCompleted(object sender, CheckAndDownloadUpdateCompletedEventArgs e)
{
if (e.UpdateAvailable)
{
//an new version has been downloaded and silverlight version is the same
//so user just has to restart application
}
else if (e.Error != null &&
e.Error …Run Code Online (Sandbox Code Playgroud) 在getMostFrequentlyOccurringItem()下面创建函数的最佳方法是什么?
//should return "paragraph"
echo getMostFrequentlyOccurringItem(array('line', 'paragraph', 'paragraph'));
//should return "line"
echo getMostFrequentlyOccurringItem(array('wholeNumber', 'line', 'line', 'line'));
//should return null
echo getMostFrequentlyOccurringItem(array('wholeNumber', 'wholeNumber', 'paragraph', 'paragraph'));
//should return "wholeNumber"
echo getMostFrequentlyOccurringItem(array('wholeNumber', '', '', ''));
function getMostFrequentlyOccurringItem($items) {
//...
}
Run Code Online (Sandbox Code Playgroud)
谢谢亚当,这是我完成的解决方案:http: //tanguay.info/web/index.php?pt = codeExamples&id = 396
作为这个问题的后续仍然试图解决Javascript函数异常,有人可以解释为什么下面的代码有效吗?
我的文字(Javascript Patterns)说明:
如果您创建一个新函数并将其分配给已经拥有另一个函数的同一个变量,那么您将使用新函数覆盖旧函数.
这将使我认为下面的代码中,变量count和name函数的第二个定义时,将重挫test创建.
变量count和name生活在哪里?
$(document).ready(function() {
var test = function() {
var name = 'The Test Function';
var count = 1;
console.log(name + ' has been setup');
test = function() {
console.log('Number of times ' + name + ' has been called: ' + count);
count++;
};
}
test();
test();
test();
test();
test();
});
Run Code Online (Sandbox Code Playgroud)

在以下字符串中的"x"之前和之后找到四位数的正则表达式是什么:
234a2343x2834o234 --> 2343, 2834
iur3333x44445555 --> 3333, 4444
owier3423x23sd --> 3423, no match
Run Code Online (Sandbox Code Playgroud) 以下示例是JavaScript中用于创建和操作对象的一种方式,即使用new Object()语法.另一种方法是创建一个对象文字.
我记得在某个地方阅读但现在无法找到它因为某种原因应该避免使用"new Object()"在JavaScript中创建对象.
是否有理由现在使用new Object()如下代码?
<html>
<head>
<title>Test Page</title>
<script type="text/javascript">
window.onload = function() {
var layout = new Object();
layout.idCode = 'simple';
layout.title = 'Simple Layout';
layout.content = '';
layout.width = 400;
layout.display = function() {
return '<div style="background-color: #eee; width:'+this.width+'">'+this.content+'</div>'
};
layout.width = 200;
layout.content = 'This is the new content';
document.getElementById('output').innerHTML = layout.display();
};
</script>
</head>
<body>
<div id="output"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 以下JQuery"表单"工作(通过ajax发送和接收数据),但如果我改变了
<div id="formContact">
Run Code Online (Sandbox Code Playgroud)
到form标签,然后它不起作用.为什么是这样?
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Testing - Test</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<script type="text/javascript" src="systemJavascript/jquery-1.4.4.min.js"></script>
<style type="text/css">
#result {
margin: 10px;
background: #eee;
padding: 10px;
height: 40px;
overflow: auto;
}
</style>
<script type="text/javascript">
$(function() {
$('#resultArea').html('click button');
$('button#formButton').click(function() {
console.log('we only get here if form is a DIV element, not a FORM element');
$('button#formButton').blur();
$('#firstName').focus();
$.post(
'testAjaxProcess2.php',
{
firstName: $('#firstName').val(),
lastName: $('#lastName').val()
},
function( jsonString )
{ …Run Code Online (Sandbox Code Playgroud) 我试图建立了多个尺寸屏幕自适应网站,如引导大小xs,sm,md,和lg.
三种较小尺寸的一切都很好,即滚动条仅在需要时出现在右侧.
但是,在大尺寸屏幕上,其宽度为1024px,因此不会太宽,如何才能使垂直滚动条仅在需要时显示?
.pagecontent {
margin: 0 18px;
}
/* bootstrap override */
.container {
width: 100%;
padding: 0;
}
.navbar {
border-radius: 0px;
}
.navbar-text {
float: left !important;
margin-right: 10px;
}
.navbar-right {
float: right!important;
}
.navbar-nav>li>a {
padding-top: 15px;
padding-bottom: 15px;
}
.navbar-nav {
margin-bottom: 0;
margin-top: 0;
margin-left: 0;
}
.container {
width: 1024px;
padding: 0;
background-color: #fff;
position: absolute;
top: 0;
bottom: …Run Code Online (Sandbox Code Playgroud)我得到了以下响应式网站,以便在所有设备上以我想要的方式工作.唯一剩下的问题是使下拉菜单可滚动,以便当下拉菜单中的选项数量超过设备屏幕上的选项数量时,有一种方法可以滚动它.
这些下拉菜单用于在开发过程中滚动,如本例所示(http://tanguay.info/testmenu2).但是,由于我需要添加固定高度等来实现这种设计,因此它有许多这些下拉菜单不可滚动.如何在保持站点的当前功能的同时恢复此可滚动功能,即保留页脚?
以下是智能手机和计算机视图中的外观:
您可以在此处查看此测试站点:http://tanguay.info/testmenu
您可以在此处下载代码:http://tanguay.info/testmenu/testmenu.zip
这是HTML:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="index_fichiers/bootstrap.css">
<link rel="stylesheet" type="text/css" href="index_fichiers/bootstrap_custom_extensions.css">
<link rel="stylesheet" type="text/css" href="index_fichiers/bootstrap_override.css">
<link rel="stylesheet" type="text/css" href="index_fichiers/system_navbarResponsiveSite.css">
<link rel="stylesheet" type="text/css" href="index_fichiers/system_reset.css">
<link rel="stylesheet" type="text/css" href="index_fichiers/system_developer.css">
<link rel="stylesheet" type="text/css" href="index_fichiers/system_main.css">
<link rel="stylesheet" type="text/css" href="index_fichiers/custom_main.css">
<link rel="stylesheet" type="text/css" href="index_fichiers/font-awesome.css">
<link rel="stylesheet" type="text/css" href="index_fichiers/lt.css">
<script src="index_fichiers/jquery-2.js"></script>
<script src="index_fichiers/bootstrap.js"></script>
<script src="index_fichiers/qtools.js"></script>
<script src="index_fichiers/system_main.js"></script>
<script src="index_fichiers/angular.js"></script>
<style type="text/css">
/* …Run Code Online (Sandbox Code Playgroud) 我有这个自定义的wpf用户控件:
ShowCustomer.xaml:
<UserControl x:Class="TestControlUpdate2343.Controls.ShowCustomer"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<TextBlock Text="{Binding Message}"/>
</Grid>
</UserControl>
Run Code Online (Sandbox Code Playgroud)
ShowCustomer.xaml.cs:
using System.Windows.Controls;
using System;
using System.ComponentModel;
namespace TestControlUpdate2343.Controls
{
public partial class ShowCustomer : UserControl, INotifyPropertyChanged
{
#region ViewModelProperty: Message
private string _message;
public string Message
{
get
{
return _message;
}
set
{
_message = value;
OnPropertyChanged("Message");
}
}
#endregion
public ShowCustomer()
{
InitializeComponent();
DataContext = this;
Message = "showing test customer at: " + DateTime.Now.ToString();
}
#region INotifiedProperty Block
public event PropertyChangedEventHandler PropertyChanged;
protected void …Run Code Online (Sandbox Code Playgroud)