我最近接受过两次电话采访,其中我被问及接口和抽象类之间的区别.我已经解释了他能想到的每一个方面,但似乎他们在等我提一些具体的东西,我不知道它是什么.
根据我的经验,我认为以下是正确的.如果我错过了重点,请告诉我.
接口:
在接口中声明的每个单独的方法都必须在子类中实现.接口中只能存在事件,代理,属性(C#)和方法.一个类可以实现多个接口.
抽象类:
只有抽象方法必须由子类实现.Abstract类可以有实现的常规方法.Abstract类还可以在Events,Delegates,Properties和Methods旁边有类变量.由于C#中不存在多重继承,因此类只能实现一个抽象类.
毕竟,面试官想出了一个问题"如果你有一个只有抽象方法的抽象类怎么办?那么它与界面会有什么不同?" 我不知道答案,但我认为这是上面提到的继承权吗?
另一位采访者问我,如果你在界面中有一个Public变量,那么它与Abstract Class有什么不同?我坚持认为你不能在界面中有一个公共变量.我不知道他想听到什么,但他也不满意.
另见:
在Twitter bootstrap中,查看模态文档.我无法弄清楚是否有办法收听模态的关闭事件并执行一个函数.
例如,我们以此模态为例:
<div class="modal-header">
<button type="button" class="close close_link" data-dismiss="modal" aria-hidden="true">×</button>
<h3>Modal header</h3>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<a href="#" class="btn close_link" data-dismiss="modal">Close</a>
</div>
Run Code Online (Sandbox Code Playgroud)
顶部的X按钮和底部的关闭按钮都可以隐藏/关闭模态data-dismiss="modal".所以我想知道,如果我能以某种方式听那个?
或者我可以像这样手动做,我猜...
$("#salesitems_modal").load(url, data, function() {
$(this).modal('show');
$(this).find(".close_link").click(modal_closing);
});
Run Code Online (Sandbox Code Playgroud)
你怎么看?
我是ReactJS的新手,如果这听起来很对不起.我有一个组件,根据收到的数据创建几个表行.
列中的每个单元格都有一个单选复选框.因此,用户可以从现有行中选择一个site_name和一个address.选择应显示在页脚中.那就是我被困住的地方.
var SearchResult = React.createClass({
render: function(){
var resultRows = this.props.data.map(function(result){
return (
<tbody>
<tr>
<td><input type="radio" name="site_name" value={result.SITE_NAME}>{result.SITE_NAME}</input></td>
<td><input type="radio" name="address" value={result.ADDRESS}>{result.ADDRESS}</input></td>
</tr>
</tbody>
);
});
return (
<table className="table">
<thead>
<tr>
<th>Name</th>
<th>Address</th>
</tr>
</thead>
{resultRows}
<tfoot>
<tr>
<td>chosen site name ???? </td>
<td>chosen address ????? </td>
</tr>
</tfoot>
</table>
);
}
});
Run Code Online (Sandbox Code Playgroud)
在jQuery中,我可以做一些类似于$("input[name=site_name]:checked").val()选择一个单选复选框类型并将其插入第一个页脚单元格的内容.
但肯定必须有一种Reactjs方式,我完全不知道了吗?非常感谢
我安装了新的Visual Studio 2012 Ultimate.
我用我的解决方案创建了一个测试项目,它包含一些默认的单元测试.但是,右键单击新方法不再显示"创建单元测试"上下文菜单.
请参阅Visual Studio 2010 Ultimate:

和Visual Studio 2012旗舰版:

知道为什么会这样吗?
更新:
Visual Studio 2012和2013的解决方案:
.net unit-testing mstest visual-studio-2012 visual-studio-2013
可能重复:
使用Pip安装特定软件包版本
我是一个有点新的pip install和virtualenv一般的.
我已经在我的服务器以及我的本地开发环境中设置了virtualenv.
在服务器上,包django_modeltranslation-0.4.0_beta2完全正常.
但是在我的本地机器django_modeltranslation-0.5.0-alpha上似乎根本不能正常工作.
我通常只需将它安装在virtual-env中,如下所示:
$ source bin/active
(env)$ pip install django_modeltranslation
Run Code Online (Sandbox Code Playgroud)
这会获得最新版本,现在这是第一次导致使用最新版本的问题.
所以我卸载了像这样的版本5 alpha:
(env)$ pip uninstall django_modeltranslation
Run Code Online (Sandbox Code Playgroud)
但现在我不知道如何才能再次获得0.4.0 Beta的工作版本.我尝试了这个,但它找不到它:
(env)$ pip install django_modeltranslation-0.4.0_beta2
Downloading/unpacking django-modeltranslation-0.4.0-beta2
Could not find any downloads that satisfy the requirement django-modeltranslation-0.4.0-beta2
No distributions at all found for django-modeltranslation-0.4.0-beta2
Run Code Online (Sandbox Code Playgroud)
我认为必须有办法,因为这是使用虚拟环境的重点.
使用私有静态只读对象来锁定多线程是很常见的.我知道私有通过收紧封装来减少锁定对象的入口点,因此可以访问最重要的内容.
但为什么静止?
private static readonly object Locker = new object();
Run Code Online (Sandbox Code Playgroud)
最后,该字段仅在我的班级中使用,我也可以使用它:
private readonly object Locker = new object();
Run Code Online (Sandbox Code Playgroud)
任何意见?
更新:
作为一个例子,我粘贴了这段代码(只是一个例子).我可以使用静态或非静态锁定器,两者都可以正常工作.考虑到下面的答案,我应该更喜欢这样定义我的储物柜?(对不起,我下周接受采访,需要知道每一个细节:)
private readonly object Locker = new object();
Run Code Online (Sandbox Code Playgroud)
以下是代码:
private int _priceA;
private int _priceB;
private EventWaitHandle[] _waithandle;
private readonly IService _service;
//ctor
public ModuleAViewModel(IService service)
{
_service = service;
_modelA = new ModelA();
_waithandle = new ManualResetEvent[2];
_waithandle[0] = new ManualResetEvent(false);
_waithandle[1] = new ManualResetEvent(false);
LoadDataByThread();
}
private void LoadDataByThread()
{
new Thread(() =>
{
new Thread(() =>
{ …Run Code Online (Sandbox Code Playgroud) 我遇到了一个有趣的情况.
class Company(models.Model):
date = models.DateField()
time = models.TimeField()
Run Code Online (Sandbox Code Playgroud)
使用此课程时:
c = Company(date=datetime.datetime.now(), time=datetime.datetime.now())
Run Code Online (Sandbox Code Playgroud)
Django决定DATETIME_INPUT_FORMATS在formats.py文件中使用defined.这是有道理的,因为我将datetime.now()传递给两个字段.
我想我能让Django的使用datetime.now()和DATE_INPUT_FORMATS分别,如果我只在当前日期和当前时间过去了.
像这样的东西:
c = Company(date=datetime.date.now(), time=datetime.time.now())
Run Code Online (Sandbox Code Playgroud)
但这引发了一个异常,因为现在不存在这样的异常.有没有不同的方法来实现这一目标?
非常感谢,
这可能听起来太琐事了,而且我做了与文章中建议的相同的事情,但它没有按预期工作.希望有人能指出我正确的方向.
我想保存每个AppSettings的用户设置.
一旦Winform关闭,我触发:
conf.Configuration config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (ConfigurationManager.AppSettings["IntegrateWithPerforce"] != null)
ConfigurationManager.AppSettings["IntegrateWithPerforce"] =
e.Payload.IntegrateCheckBox.ToString();
else
config.AppSettings.Settings.Add("IntegrateWithPerforce",
e.Payload.IntegrateCheckBox.ToString());
config.Save(ConfigurationSaveMode.Modified);
Run Code Online (Sandbox Code Playgroud)
因此,当条目第一次不存在时,它只会创建它,否则它将修改现有条目.然而,这并不节省.
1)我做错了什么?
2)我希望在哪里再次保存应用程序设置的用户设置?是在Debug文件夹中还是在C:\ Documents and Settings\USERNAME\Local Settings\Application Data文件夹中?
我在理解如何为django设计单元测试时遇到问题.
根据我的理解,一次性测试整个视图似乎是不可能的.我们需要区分请求的前后状态.但我不知道如何设计这个.有没有现实生活中的例子?
查看文档,示例过于简化,仅关注模型.
@login_required
def call_view(request, contact_id):
profile = request.user.get_profile()
if request.POST:
form = CallsForm(profile.company, request.POST)
if form.is_valid()
return HttpResponseRedirect('/contact/' + contact_id + '/calls/')
else:
form = CallsForm(profile.company, instance=call)
variables = RequestContext(request, {'form':form}
return render_to_response('conversation.html', variables)
Run Code Online (Sandbox Code Playgroud)
更新:
试图成功测试工作,但它仍然失败:
def test_contact_view_success(self):
# same again, but with valid data, then
self.client.login(username='username1', password='password1')
response = self.client.post('/contact/add/', {u'last_name': [u'Johnson'], })
self.assertRedirects(response, '/')
Run Code Online (Sandbox Code Playgroud)
错误信息:
AssertionError: Response didn't redirect as expected: Response code was 200 (expected 302)
Run Code Online (Sandbox Code Playgroud)
我认为这是因为form.is_valid()失败并且它没有重定向,对吗?
我已经升级到Xcode 10对High Sierra现在的回报广告示例项目来自AdMob抱怨说,com.apple.commcenter.coretelephony.xpc不能正常工作.
我必须启用新的权利吗?我正在寻找几个小时没有任何线索.
更新: 这只发生在模拟器上.在设备上它工作正常.他们必须增加一个新的限制.
2018-09-22 10:59:39.730813+0100 RewardedVideoExample[1449:26168] libMobileGestalt MobileGestalt.c:890: MGIsDeviceOneOfType is not supported on this platform.
2018-09-22 10:59:40.031746+0100 RewardedVideoExample[1449:26281] Failed to create remote object proxy: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}
2018-09-22 10:59:40.031865+0100 RewardedVideoExample[1449:26261] Failed to ping server after delegate was set
2018-09-22 10:59:40.031938+0100 RewardedVideoExample[1449:26262] Failed to create synchronous remote object proxy: Error Domain=NSCocoaErrorDomain Code=4099 "The connection …Run Code Online (Sandbox Code Playgroud) .net ×2
c# ×2
django ×2
python ×2
unit-testing ×2
admob ×1
appsettings ×1
html ×1
interface ×1
jquery ×1
locking ×1
modal-dialog ×1
mstest ×1
oop ×1
pip ×1
reactjs ×1
settings ×1
virtualenv ×1
xcode ×1
xcode10 ×1