不匹配(卷曲)括号

编程入门 行业动态 更新时间:2024-10-26 17:30:55
本文介绍了不匹配(卷曲)括号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

嗨!

我刚刚开始在uni的编程(C#),并在下周五开始我的第一次考试。但是刚才,我的项目开始与我的大括号不匹配,我似乎无法解决它。

I just started at programming (C#) at uni and have my first exam next friday. But just now, my project started to mismatch all my curly brackets and I can't seem to fix it.

更多地定义我的问题:当我放置一个开口的组合时例如,在一个类之后关闭括号(即"{}"),并继续创建一个方法(再次添加一对新的花括号),该类的左括号与匹配,结束括号方法。这导致"错误"代码。

To define my problem a bit more: When I place the combination of a opening and closing bracket (i.e. "{}") after a class for example, and continue to create a method (adding a new pair of curly brackets again) the opening bracket of the class matches with the closing bracket of the method. Which results in a "wrong" code.

我有点绝望,希望你们可以帮我解决这个问题。

I'm kinda desperate and was hoping you guys could help me out in fixing this.

提前致谢!

推荐答案

很难确切知道什么是没有看到你的代码(以及你得到的确切错误消息)错误。但通常你的文件应该是这样的:

Difficult to know exactly what is wrong without seeing your code (and the exact error message you are getting). But generally your file should look something like this: using System; // any other assemblies used would go here namespace MyNamespace { public class MyClass { public void MethodOne() { } public int MethodTwo(int anArgument) { return anArgument * 2; } } }

显然这是一个毫无意义的类 - 它只是基本语法的演示。它是一个名为MyClass的简单类,它包含两个方法。 MethodOne不接受任何参数或返回任何内容。 MethodsTwo接受一个整数参数并返回传入的数字的两倍。

Obviously this is a meaningless class - it's just a demonstration of the basic syntax. Its a simple class called MyClass that contains two methods. MethodOne does not take any arguments or return anything. MethodsTwo takes a single integer argument and returns double the number passed in.

更多推荐

不匹配(卷曲)括号

本文发布于:2023-06-06 04:41:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/534726.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:卷曲   括号   不匹配

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!