Пространство имен не может напрямую содержать такие элементы, как поля, методы или операторы. ⇐ C#

Место общения программистов C#
Anonymous
Пространство имен не может напрямую содержать такие элементы, как поля, методы или операторы.

Сообщение Anonymous »

Внезапно я начал получать эту ошибку. Только эта бритва-страница выдает ошибку!
Пространство имен не может напрямую содержать такие элементы, как поля, методы или операторы
Последнее, что я сделал, это опубликовал свой сервер blazor, чтобы посмотреть, работает он или нет. Я попытался очистить папки bin и obj, но все равно получаю ту же ошибку. Я искал везде, пытался перезагрузиться, закрыть VS2022 и открыть его снова, но все то же самое.
@inject IOptionService OptionService
@inject ModalService ModalServices

private string GenerateHtmlPreview()
{
bool hasEmptyData = false;
string html = @"";
int qId = 0, aId = 0;
foreach (var section in sections)
{
if (section.archived)
continue;
html += @"";
if (!string.IsNullOrEmpty(section.title))
html += @"" + section.title + "";
else hasEmptyData = true;
foreach (var question in section.questions)
{
qId++;
if (question.archived)
continue;
if (!string.IsNullOrEmpty(question.text))
{
html += @"" + question.text + "";
switch (question.type)
{
case FieldType.SingleLineText:
html += @$"";
break;
case FieldType.ParagraphText:
html += @$"";
break;
case FieldType.Date:
html += @"";
break;
case FieldType.MultipleChoices:

foreach (var item in question.answers)
{
++aId;
if (item.archived)
continue;
if (!string.IsNullOrEmpty(item.text))
{
html += $@"{item.text}";
}
}
html += "";
break;
case FieldType.Checkboxes:

foreach (var item in question.answers)
{
if (item.archived)
continue;
if (!string.IsNullOrEmpty(item.text))
{
html += $@"{item.text}";
}
}
html += "";
break;
}
}
else hasEmptyData = true;
}
html += "";
}
if (hasEmptyData)
html = $@"Empty fields are not included in the preview." + html;
html += "";
return html;
}


Подробнее здесь: https://stackoverflow.com/questions/791 ... -statement

Вернуться в «C#»