构造函数属性.txt
来自「c语言多个实用小程序,会有帮助的~ 自己瞎编的」· 文本 代码 · 共 37 行
TXT
37 行
using System;
public class Square
{
private int sidelong;
public Square()
{
Console.WriteLine ("我没有参数.");
}
public Square(int sidelong)
{
this.sidelong=sidelong;
}
public int Setsidelong(int sidelong)
{
this.sidelong=sidelong;
return sidelong;
}
public int Getsidelong(int sidelong)
{
return sidelong;
}
public void Print()
{
Console.WriteLine ("当前正方形的边长是:{0}",sidelong);
}
}
class Square_Test
{
public static void Main()
{
Square s1=new Square ();
s1.Setsidelong (4);
s1.Print ();
Square s2=new Square ();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?