.NET Core(ASP.NET全体)にはかなり新しく、私の見解の中にC#関数を作成しようとすると何かが間違っているのだろうかと疑問に思っていた。.NET Core Razor C#関数
(Collections.cshtml)を次のように私の見解がある
すべてが正常に動作してい私はそれが何をしたいのかが、私は機能にそれを整理したり、基本的な機能を追加しようとする場合、それは怒鳴るように壊れる<h2>Collections</h2>
<div id="content">
@{
// define variables
List<string> collections;
int counter;
// build list
collections = new List<string>();
collections.Add("Nothing 01");
collections.Add("Nothing 02");
// display list
counter = 0;
while(counter < collections.Count)
{
<p>@collections[counter]</p>
counter = counter + 1;
}
}
</div>
@{
// function for no reason
public void testFunc()
{
string nothing;
nothing = null;
return;
}
}
<h2>Collections</h2>
<div id="content">
@{
// define variables
List<string> collections;
int counter;
// build list
collections = new List<string>();
collections.Add("Nothing 01");
collections.Add("Nothing 02");
// display list
counter = 0;
while(counter < collections.Count)
{
<p>@collections[counter]</p>
counter = counter + 1;
}
}
</div>
はちょうどその機能を追加すると、それを破壊し、
を教えていない「ことが壊れます」あなたが得ているエラーについて何か。 –
古いコードはすべて変数が宣言されていないと言っています。ページを実行すると、 '} expected'や 'identifier expected'や 'expected expected'のような行と行のエラーが表示されます。エラー – Trent
質問を編集して、最小限の完全な例(すべてのエラーメッセージをそのまま含む)を表示してください。私は質問が今答えられ、閉鎖されていることを知っているが、それを改善するにはそれほど遅くはない。 –