当我们创建一个从抽象类继承的类并且当我们实现继承的抽象类时,为什么我们必须使用 override 关键字?
public abstract class Person
{
public Person()
{
}
protected virtual void Greet()
{
// code
}
protected abstract void SayHello();
}
public class Employee : Person
{
protected override void SayHello() // Why is override keyword necessary here?
{
throw new NotImplementedException();
}
protected override void Greet()
{
base.Greet();
}
}
Run Code Online (Sandbox Code Playgroud)
由于该方法在其父类中被声明为抽象的,它在父类中没有任何实现,那么为什么这里需要关键字 override 呢?
你能告诉我为什么填充没有在这里应用,即使我在我的app.component.css文件中将padding-top设置为20px.如果我在styles.css文件中设置它将会工作.当我将css属性移动到app.component.css文件时,不确定它为什么不起作用.
app.component.ts文件:
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
}
Run Code Online (Sandbox Code Playgroud)
app.component.html文件:
<mat-tab-group class="redThis">
<mat-tab label="Tab 1">Content 1</mat-tab>
<mat-tab label="Tab 2">Content 2</mat-tab>
</mat-tab-group>
Run Code Online (Sandbox Code Playgroud)
app.component.css文件
.mat-tab-body-content{
padding-top:20px;
}
Run Code Online (Sandbox Code Playgroud) 有人可以解释一下这两行代码在我的 WebApiConfig.cs 文件的 Register() 方法中的含义。
// Web API configuration and services
// Configure Web API to use only bearer token authentication.
config.SuppressDefaultHostAuthentication();
config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));
Run Code Online (Sandbox Code Playgroud)
我假设它添加了 HostAuthentication 应用程序。但即使我没有在我的请求中传递不记名令牌,我仍然能够获取数据。那么添加这个过滤器有什么意义呢?
当我右键单击int我的代码并选择"转到定义"时,Visual Studio会打开一个名为"Int32 [来自元数据]"的文件.该文件包含以下行:
public const Int32 MinValue = --2147483648;
Run Code Online (Sandbox Code Playgroud)
双重标志是什么意思?
我正在运行Visual Studio 15.8.4.根据评论中的信息,这在Visual Studio 2017的所有版本上都不可重现.
我有一个存储过程,我使用事务从 ac# 代码调用它。当我在 C#(它是一个控制台应用程序)中运行代码时,我没有从 catch 块中获取结果,而是抛出了一个异常,说:
在批处理结束时检测到不可提交的事务。事务回滚。
C#代码:
using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
namespace app1
{
class Program
{
static void Main(string[] args)
{
string res = "";
string resDesc = "";
res = WriteToDB(1,out resDesc);
Console.WriteLine(res);
Console.WriteLine(resDesc);
Console.Read();
}
public static string WriteToDB(int val, out string resultDesc)
{
resultDesc = "";
string result = "";
string connectionString = ConfigurationManager.ConnectionStrings["SqlAppConnection"].ConnectionString;
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
SqlTransaction transaction = connection.BeginTransaction("transcation1");
try
{
using (SqlCommand cmd …Run Code Online (Sandbox Code Playgroud) app.module.ts 文件中列出的路径顺序重要吗?例如...
RouterModule.forRoot([
{path:'',component:HomeComponent},
{path:'followers',component:GithubFollowersComponent},
{path:'followers/:username/:userid',component:GithubProfileComponent},
{path:'posts',component:PostsComponent},
{path:'**',component:NotFoundComponent}
])
Run Code Online (Sandbox Code Playgroud)
对比..
RouterModule.forRoot([
{path:'',component:HomeComponent},
{path:'followers/:username/:userid',component:GithubProfileComponent},
{path:'followers',component:GithubFollowersComponent},
{path:'posts',component:PostsComponent},
{path:'**',component:NotFoundComponent}
])
Run Code Online (Sandbox Code Playgroud)
我正在看一个教程,它说顺序很重要..但我尝试了两种方法,它们似乎都按预期工作......
如果我将通配符路径( ** )移到顶部,那么是的,我确实注意到了差异。但是对于其他人来说,顺序根本不重要吗?还是我在这里遗漏了什么?....
我收到一条错误消息,指出标签上的 prop 'component' 值无效。
下面是我的组件中的代码。
<Link to="/posts" component={Posts}>
See Posts
</Link>
Run Code Online (Sandbox Code Playgroud)
这个错误是什么意思?
有人可以解释为什么我的懒加载组件永远不会加载吗?
所看到的只是消息加载...在屏幕上...并且没有错误。
下面是我的代码:
import React, { Component, lazy, Suspense } from "react";
import "./App.css";
//const Mycomp = lazy(() => import("./components/myComp"));
const Mycomp = lazy(() => {
let x = new Promise(
() => {
import("./components/myComp");
},
e => {
console.log(e);
}
);
return x;
});
class App extends Component {
sayHi = () => {
console.log("supa");
};
render() {
return (
<Suspense fallback={<div> loading...</div>}>
<div className="App">
<header className="App-header">
<Mycomp />
<input type="button" value="sayHi" onClick={this.sayHi} />
</header>
</div>
</Suspense>
);
} …Run Code Online (Sandbox Code Playgroud) 我有一个 asp.net core razor 页面,其中有一个简单的表单,要求提供用户电子邮件地址和提交按钮。当我输入电子邮件并单击提交按钮时,我总是收到 400 错误
HTTP 错误 400
我不确定我在这里做错了什么。我尝试在 OnPost 方法中放置一个断点,但我什至没有达到那个点。
下面是我的代码:
好人.cshtml
@page
@model WebApplication1.Pages.HomieModel
@{
ViewData["Title"] = "Homie";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h1>Homie</h1>
<form method="post">
<input type="email" name="emailaddress">
<input type="submit">
</form>
Run Code Online (Sandbox Code Playgroud)
好人.cshtml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace WebApplication1.Pages
{
public class HomieModel : PageModel
{
public void OnGet(string n)
{
}
public void OnPost()
{
var emailAddress = Request.Form["emailaddress"];
// do something with emailAddress
}
}
}
Run Code Online (Sandbox Code Playgroud)
import ipywidgets as widgets
button = widgets.Button(description="Click Me!")
output = widgets.Output()
display(button, output)
def on_button_clicked():
print("button clicked")
button.on_click(on_button_clicked)
Run Code Online (Sandbox Code Playgroud)
该按钮出现了..但是当我单击该按钮时,我希望看到“已单击按钮”消息出现。但这并没有发生。
我在这里缺少什么吗?
我正在使用 vscode 来运行我的 jupyter 笔记本。
c# ×5
angular ×2
reactjs ×2
asp.net-core ×1
ipywidgets ×1
javascript ×1
owin ×1
python ×1
razor-pages ×1
sql ×1
sql-server ×1
t-sql ×1