c# 中 get 和set

来源:百度知道 编辑:UC知道 时间:2024/05/14 14:33:40
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication9
{
class Program
{
calss point
{

public int x
{
get
{
return myx;
}

set
{
myx=value;
}
}

public int y

{
aet
{
myy=value;
}
get
{
return myy;
}
}
private Int32 myx;
private Int32 myy;
}
}

static void Main(string[] args)
{
Console.WriteLine("saas");
}
}
}

这个编译通不过说是什么 应为get set 什么的

主要问题是你的大括号配对有问题,
我把你的代码整理了了下,编译已经通过了,你看看吧:
顺便说一下:你用了一个嵌套类,那个不是问题,也不会出错,但是如果没有必要还是别用嵌套类吧

using System;
using System.Text;

namespace ConsoleApplication9
{
class Program
{
class point
{
public int x
{
get
{
return myx;
}
set
{
myx=value;
}
}

public int y
{
set
{
myy=value;
}
get
{
return myy;
}
}
private Int32 myx;
private Int32 myy;

static void Main(string[] args)
{
Console.WriteLine("saas");
}
}
}
}

public int y

{
aet
{
myy=value;
}
get