ошибка CS1022: ожидается определение типа или пространства имен или конец файла
Я создаю приложение для обмена сообщениями для andriod / ios, но я совершенно новичок в c # и работе с сетями, я прошел первые шаги простого руководства по сокетам, чтобы начать работу в сети (https://www.youtube.com/watch?v=KxdOOk6d_I0), но я получаю сообщение об ошибке:
ошибка «CS1022: определение типа или пространства имен или ожидаемый конец файла».
Я предполагаю, что это как-то связано с пространством имен, потому что я новичок в c # и на самом деле не понимаю, что делает пространство имен, но мой компилятор говорит, что ошибок нет (я использую код Visual Studio, если это имеет значение ) но это может быть что-то еще.
Он должен сказать сервер запущен . «или выдать исключение, но это то, что я получаю каждый раз:
[Запуск] моно «C: Users Aidan AppData Roaming Code User cs-script.user cscs.exe» «d:! Информатика !! NEA! Test stuff network server_test program. cs «Ошибка: указанный файл не может быть скомпилирован.
csscript.CompilerException: d:! computer science !! NEA! test stuff network server_test program.cs (7,127): ошибка CS1513:> ожидается d:! computer science !! NEA! test stuff network server_test program.cs (37,1): ошибка CS1022: определение типа или пространства имен или ожидаемый конец файла
at csscript.CSExecutor.ProcessCompilingResult (результаты System.CodeDom.Compiler.CompilerResults, System.CodeDom.Compiler.CompilerParameters compilerParams, синтаксический анализатор CSScriptLibrary.ScriptParser, System.String scriptFileName, дополнительное имя System.String [0], [0]. в: 0 в csscript.CSExecutor.Compile (System.String scriptFileName) [0x0080d] в: 0 в csscript.CSExecutor.ExecuteImpl () [0x005a1] в: 0
[Готово] выход с кодом = 1 через 1,795 секунды
Источник
error CS1022: Type or namespace definition, or end-of-file expected
I’m creating a messaging application for andriod/ios, but I am completely new to c# and networking, I’ve followed the first steps of a simple socket tutorial to get me started in networking (https://www.youtube.com/watch?v=KxdOOk6d_I0) but I get the error:
error «CS1022: Type or namespace definition, or end-of-file expected».
I’m assuming that it has something to do with the namespace because im new to c# and don’t actually understand what the namespace does, but my compiler says there are no errors (I’m using visual studio code if that makes a difference) but it may be something else.
it should say server started. » or throw up an exeption but this is what im getting every time:
[Running] mono «C:UsersAidanAppDataRoamingCodeUsercs-script.usercscs.exe» «d:!computer science!!NEA!test stuffnetworkingserver_testprogram.cs» Error: Specified file could not be compiled.
csscript.CompilerException: d:!computer science!!NEA!test stuffnetworkingserver_testprogram.cs(7,127): error CS1513: > expected d:!computer science!!NEA!test stuffnetworkingserver_testprogram.cs(37,1): error CS1022: Type or namespace definition, or end-of-file expected
at csscript.CSExecutor.ProcessCompilingResult (System.CodeDom.Compiler.CompilerResults results, System.CodeDom.Compiler.CompilerParameters compilerParams, CSScriptLibrary.ScriptParser parser, System.String scriptFileName, System.String assemblyFileName, System.String[] additionalDependencies) [0x00102] in :0 at csscript.CSExecutor.Compile (System.String scriptFileName) [0x0080d] in :0 at csscript.CSExecutor.ExecuteImpl () [0x005a1] in :0
[Done] exited with code=1 in 1.795 seconds
Источник
I’m fairly new to c# and unity and I don’t know what this error means, i’m trying to make the floor tilt like in super monkey ball, I know how it all works but I copied and pasted it so to not make mistakes and to save time.
This is the code, please help
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Floor_Control : MonoBehaviour{}
{
public float speed;
public float max;
void FixedUpdate()
{
//Player Input
float step = speed * Time.deltaTime;
float tiltX = -Input.GetAxis("Horizontal") + Input.GetAxis("Vertical");
float tiltZ = Input.GetAxis("Horizontal") + Input.GetAxis("Vertical");
GetComponent<Rigidbody>().rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.Euler(max * tiltZ, 0, max * tiltX), step);
}
}
asked Jan 15, 2020 at 19:44
3
Remove the braces after MonoBehaviour «{}». You also don’t have a namespace declaration which may also generate that error message:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace TestProgram
{
public class Floor_Control : MonoBehaviour
{
public float speed;
public float max;
void FixedUpdate()
{
//Player Input
float step = speed * Time.deltaTime;
float tiltX = -Input.GetAxis("Horizontal") + Input.GetAxis("Vertical");
float tiltZ = Input.GetAxis("Horizontal") + Input.GetAxis("Vertical");
GetComponent<Rigidbody>().rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.Euler(max * tiltZ, 0, max * tiltX), step);
}
}
}
answered Jan 15, 2020 at 20:02
Mark McWhirterMark McWhirter
1,1483 gold badges11 silver badges28 bronze badges
1
Permalink
Cannot retrieve contributors at this time
title | ms.date | ms.prod | ms.technology | ms.topic | f1_keywords | dev_langs | helpviewer_keywords | ms.assetid | caps.latest.revision | author | ms.author | translation.priority.ht | translation.priority.mt | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Compiler Error CS1022 | Microsoft Docs |
2015-07-20 |
.net |
devlang-csharp |
article |
CS1022 |
CSharp |
CS1022 |
76b9f32b-2ebf-471d-a635-852daf8877d7 |
6 |
BillWagner |
wiwagn |
|
|
Compiler Error CS1022
Type or namespace definition, or end-of-file expected
A source-code file does not have a matching set of braces.
The following sample generates CS1022:
// CS1022.cs
namespace x
{
}
} // CS1022
Permalink
Cannot retrieve contributors at this time
title | ms.date | ms.prod | ms.technology | ms.topic | f1_keywords | dev_langs | helpviewer_keywords | ms.assetid | caps.latest.revision | author | ms.author | translation.priority.ht | translation.priority.mt | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Compiler Error CS1022 | Microsoft Docs |
2015-07-20 |
.net |
devlang-csharp |
article |
CS1022 |
CSharp |
CS1022 |
76b9f32b-2ebf-471d-a635-852daf8877d7 |
6 |
BillWagner |
wiwagn |
|
|
Compiler Error CS1022
Type or namespace definition, or end-of-file expected
A source-code file does not have a matching set of braces.
The following sample generates CS1022:
// CS1022.cs
namespace x
{
}
} // CS1022