想知道以下几点之间的区别:
案例1:基类
public void DoIt();
Run Code Online (Sandbox Code Playgroud)
案例1:继承的类
public new void DoIt();
Run Code Online (Sandbox Code Playgroud)
案例2:基类
public virtual void DoIt();
Run Code Online (Sandbox Code Playgroud)
案例2:继承的类
public override void DoIt();
Run Code Online (Sandbox Code Playgroud)
根据我运行的测试,情况1和2似乎具有相同的效果.有区别,还是首选方式?
我理解StringBuilder的好处.
但是如果我想连接2个字符串,那么我认为没有StringBuilder它会更好(更快).它是否正确?
在什么时候(字符串的数量)使用StringBuilder会变得更好?
这段代码:
using (EntityConnection conn = new EntityConnection("name=ELSCommonEntities"))
{
conn.Open();
}
Run Code Online (Sandbox Code Playgroud)
给我以下错误:
Test method ELS.Service.Business.IntegrationTest.Base.ServiceBaseIntegrationTest.StartLoggingTestMethod threw exception: System.Data.MetadataException: Unable to load the specified metadata resource..
Run Code Online (Sandbox Code Playgroud)
使用以下堆栈跟踪:
System.Data.Metadata.Edm.MetadataArtifactLoaderCompositeResource.LoadResources(String assemblyName, String resourceName, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver)
System.Data.Metadata.Edm.MetadataArtifactLoaderCompositeResource.CreateResourceLoader(String path, ExtensionCheck extensionCheck, String validExtension, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver)
System.Data.Metadata.Edm.MetadataArtifactLoader.Create(String path, ExtensionCheck extensionCheck, String validExtension, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver)
System.Data.EntityClient.EntityConnection.SplitPaths(String paths)
System.Data.EntityClient.EntityConnection.GetMetadataWorkspace(Boolean initializeAllCollections)
System.Data.EntityClient.EntityConnection.InitializeMetadata(DbConnection newConnection, DbConnection originalConnection, Boolean closeOriginalConnectionOnFailure)
System.Data.EntityClient.EntityConnection.Open()
ELS.Service.Business.Base.ServiceBase.StartLogging(String userWindowsLogon) in C:\C-TOM\ELS-RELEASE1\ELS.Service.Business\Base\ServiceBase.cs: line 98
ELS.Service.Business.IntegrationTest.Base.ServiceBaseIntegrationTest.StartLoggingTestMethod() in C:\C-TOM\ELS-RELEASE1\ELS.Service.Business.IntegrationTest\Base\ServiceBaseIntegrationTest.cs: line 65
Run Code Online (Sandbox Code Playgroud)
但是,此代码使用相同的连接字符串:
using (ELSCommonEntities db = …Run Code Online (Sandbox Code Playgroud) 我们有一个包含很长字符串的变量的单元测试.
问题是如何在代码中编写它,没有换行问题或代码难以阅读.
在VB中有一个行继续字符,在C#中是否存在等价物?
当我们构建解决方案或错误引用的特定项目时,我们在构建服务器上收到上述错误消息.
我们可以使用visual studio(也在构建服务器上)构建解决方案而没有任何问题,但是在运行msbuild时它会因上述错误而失败.
有任何想法吗?
我们已经能够创建一个网站.我们使用此链接中的信息执行此操作:
https://msdn.microsoft.com/en-us/library/ms525598.aspx
但是,我们想使用端口号80以外的端口号.我们如何做到这一点?
我们正在使用IIS 6
我们需要列表时使用List.我现在注意到有一个LinkedList.
我想知道这两个之间有什么区别,什么时候应该使用另一个.
我正在进行代码审查,并找到了许多具有以下格式的代码:
public MyResponse MyMethod(string arg)
{
using (Tracer myTracer = new Tracer(Constants.TraceLog))
{
MyResponse abc = new MyResponse();
// Some code
return abc;
}
}
Run Code Online (Sandbox Code Playgroud)
当我运行代码分析时,我得到一个CA2000警告Microsoft.Reliability
应该将代码重写为:
public MyResponse MyMethod(string arg)
{
MyResponse abc = new MyResponse();
using (Tracer myTracer = new Tracer(Constants.TraceLog))
{
// Some code
}
return abc;
}
Run Code Online (Sandbox Code Playgroud)
或者没关系?
编辑
报告警告的行是:
MyResponse abc = new MyResponse();
Run Code Online (Sandbox Code Playgroud)
MyResponse是标准的数据集.
完整的错误消息是:
警告150 CA2000:Microsoft.Reliability:在方法'xxxxx(Guid,Guid)'中,对象'MyResponse'未沿所有异常路径放置.在对所有引用超出范围之前,在对象'MyResponse'上调用System.IDisposable.Dispose.
我试图测试canvas标签,我开始使用这段代码:
<html>
<canvas id="example" width="200" height="200">
This text is displayed if your browser does not support HTML5 Canvas.
</canvas>
</html>
Run Code Online (Sandbox Code Playgroud)
在IE8中,我收到消息:
This text is displayed if your browser does not support HTML5 Canvas.
Run Code Online (Sandbox Code Playgroud)
然后我安装了IE9但得到了同样的错误.IE9是否支持HTML5画布?
编辑
问题是我错过了doctype标签
<!DOCTYPE html>
Run Code Online (Sandbox Code Playgroud) 我们有一个遵循MVVM模式的WPF项目.
在View Model中有很多代码如下所示:
private string m_Fieldname;
public string Fieldname
{
get { return m_Fieldname; }
set
{
m_Fieldname = value;
OnPropertyChanged("Fieldname");
}
}
Run Code Online (Sandbox Code Playgroud)
有没有办法做到这需要更少的代码?
对这样的事情会很好:
[NotifyWhenChanged]
public string Fieldname { get; set ; }
Run Code Online (Sandbox Code Playgroud) c# ×7
.net-3.5 ×1
c#-4.0 ×1
canvas ×1
html5 ×1
iis ×1
iis-6 ×1
inheritance ×1
msbuild ×1
new-operator ×1
overriding ×1
port ×1
return ×1
team-build ×1
tfs ×1
wpf ×1