不匹配(卷曲)括号 [英] Mismatching (Curly) Brackets

查看:93
本文介绍了不匹配(卷曲)括号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!

我刚刚开始在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.


这篇关于不匹配(卷曲)括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆