您的位置:首页 > 编程语言 > C#

c#学习笔记(曾瑛)2

2017-09-20 10:42 267 查看

1.以对象为成员/静态成员

静态变量(静态字段)

静态函数(静态方法)

2.常量成员

const常量

readonly常量

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
}
class Hotel
{
public readonly int roomNumber;
public int guestNumber = 0;
public Hotel(int roomNumberValue)
{
roomNumber = roomNumberValue;
}
private bool IsFull()
{
if (guestNumber >= roomNumber)
return true;
else
return false;
}
public void LodgeIn()
{
if (IsFull())
Console.WriteLine("对不起,房间已满.");
else
{
guestNumber++;
Console.WriteLine("入住成功");
}
}
}
}
}


3.重载

运算符重载



4.this关键字/数组在方法和属性中的的传递

数组在方法中的传递-索引器

数组在属性中的传递

索引器

索引器访问离散字段
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: