![](/img/trans.png)
[英]Error CS0103: The name '_context' does not exist in the current context
[英]Blazor CS0103: "The name 'lines' does not exist in the current context
您好 stackoverflow 社區,我收到錯誤 CS0103 我已經搜索了谷歌但找不到答案,如果這是一個不好的問題,我是 Blazor 的新手。
我正在嘗試從逗號分隔的文件中制作表格。
@page "/fetchdata"
<PageTitle>Keyword analytics</PageTitle>
@using BlazorApp.Data
<h1>Keyword Analytics</h1>
<table class="table">
<thead>
<tr>
<th>Keyword</th>
<th>Volume</th>
<th>Competition</th>
<th>Results</th>
</tr>
</thead>
<tbody>
@foreach (var line in lines)
{
<tr>
<td>@line[0]</td>
<td>@line[1]</td>
<td>@line[2]</td>
<td>@line[3]</td>
</tr>
}
</tbody>
</table>
@code
{
protected override void OnInitialized()
{
string[] lines = File.ReadAllLines(@"C:\Users\someone\Desktop\max\BlazorApp\Something.txt");
foreach (var line in lines)
{
line.Split(';');
}
}
}
您已經在方法中聲明了lines
,因此它是該方法私有的。
@code
{
string[] lines = Array.Empty<string>();
protected override void OnInitialized()
{
lines = File.ReadAllLines(@"C:\Users\ra1n\Desktop\max\BlazorApp\SemRUSH.txt");
foreach (var line in lines)
{
line.Split(';'); // This does not do anything except waste CPU
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.