我是 SPA 框架和 Blazor 的新手,因此这可能是一个很容易回答的问题,尽管我在其他地方找不到答案。
我想在用户单击特定按钮后立即在页面上的某个位置显示一个组件。我目前是这样实现的:
@page "/test"
<button type="button" @onclick="() => showSignUpComponent = true">
Show Sign Up Window
</button>
@if (showSignUpComponent)
{
<SignUp />
}
@code {
bool showSignUpComponent;
}
Run Code Online (Sandbox Code Playgroud)
我想知道是否有更好、更干净的方法(即正确的方法)在 Blazor 中执行类似的操作,或者这是常见的“标准”方法?
如何检查char
c# 中 a 是大写还是小写,以及 a 中的每个字母string
是大写还是小写?
Account
我有一个存储在 中的对象列表AccountList
。现在我想删除一个Account
so,如果我仍然拥有该对象,我也无法将其再次添加到列表中 - 这意味着该对象根本不应该再存在。
在我的代码中,我浏览列表AccountList
并搜索Account
匹配的id
. Account
然后,当找到匹配时,Account
应该将其删除(因此也从 中删除AccountList
)。
public bool Delete_Account(int id)
{
foreach (var account in AccountList)
{
if (account.id == id)
{
//delete Account object here
return true;
}
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
这在 C# 中可能吗?如果不可能,我将如何实现我想要做的事情?
我有一个包含整数的列表,所有整数都从 0 到 2。现在我必须检查这些数字中的任何一个是否恰好出现 3 次。那怎么查呢?
例子:
{ 2, 1, 0, 0, 1, 0 } //this is true
{ 1, 1, 2, 0, 0 } //this is false
{ 0, 0, 0, 1, 1, 1, 2, 2, 2 } //this is true
Run Code Online (Sandbox Code Playgroud)