C#_修饰符的学习:
2008-12-16 23:47
267 查看
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class xiushifu //用CLASS来创建一个类
{
public int a;//访问不受限制;
private int b;//私有的,只有包含此字段的类可以访问;
protected int c;//仅在当前类和派生类中可以访问;
internal int d;//仅在当前命名空间里可以访问;
int e;//没有修饰符,默认是私有的字段:
public int B//创建一个属性,记住和方法的不同之处是属性的签名后面没有括号,而方法是有括号的
{
get { return this.b; }
protected set { this.b = value; }//如果属性中没有SET,说明此属性是只读属性,
}
}
class xiushifu2 : xiushifu
{
public int x;
public int b()//创建一个方法,记住与属性的区别哟
{
base.B=123;
return base.B;
}
}
}
=============
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
xiushifu2 x = new xiushifu2();
Console.WriteLine(x.b());
}
}
}
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class xiushifu //用CLASS来创建一个类
{
public int a;//访问不受限制;
private int b;//私有的,只有包含此字段的类可以访问;
protected int c;//仅在当前类和派生类中可以访问;
internal int d;//仅在当前命名空间里可以访问;
int e;//没有修饰符,默认是私有的字段:
public int B//创建一个属性,记住和方法的不同之处是属性的签名后面没有括号,而方法是有括号的
{
get { return this.b; }
protected set { this.b = value; }//如果属性中没有SET,说明此属性是只读属性,
}
}
class xiushifu2 : xiushifu
{
public int x;
public int b()//创建一个方法,记住与属性的区别哟
{
base.B=123;
return base.B;
}
}
}
=============
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
xiushifu2 x = new xiushifu2();
Console.WriteLine(x.b());
}
}
}
相关文章推荐
- C#学习之特殊修饰符
- C#学习之类的访问修饰符
- C#学习笔记---修饰符,this关键字和static关键字
- .Net学习笔记----2015-07-21(C#基础复习07,关键字、访问修饰符)
- C#学习笔记-方法和修饰符
- C#学习之修饰符
- C#学习之修饰符
- c# 修饰符学习
- C#学习基本概念之访问修饰符
- 【KK学习笔记】c# 参数修饰符 out ref params
- 学习C#修饰符:类修饰符和成员修饰符
- C#学习-图解教程(2):访问修饰符(其中两种)
- C# 修饰符 学习整理
- 【C#学习】访问限制修饰符
- .Net学习 第2季08 C#面向对象 访问修饰符 序列化/反序列化 部分类 密封类
- C#学习日记21----封装 与 访问修饰符
- C#--virtual,abstract,override,new,sealed修饰符学习
- C#.NET学习笔记---C#中类的修饰符,this关键字和static关键字
- C#学习基本概念之new修饰符
- 学习C#修饰符:类修饰符和成员修饰符