C#里类的get和set方法编写和调用
2016-12-03 10:25
267 查看
using System; class Date { int day; int month; int year; public int Day{ get { return day; } set { day = value; } } public int Month{ get { return month; } set { month = value; } } public int Year{ get { return year; } set { year = value; } } public bool IsLeapYear(int year) { return year%4== 0 ? true: false; } public void SetDate (int day, int month, int year) { this.day = day; this.month = month; this.year = year; } }
方法的调用
class User { public static void Main() { Date date = new Date(); date.Day = 27; date.Month = 6; date.Year = 2003; Console.WriteLine ("Date: {0}/{1}/{2}", date.Day, date.Month, date.Year); } }
相关文章推荐
- com调用的几种方法 及 C#调用C++编写的的COM DLL
- C#学习笔记: 关于get和set方法
- 根据属性名字调用相应的get和set方法
- 使用反射调用set和get方法
- Delphi 调用C#编写的WebService 参数为Null解决方法
- com调用的几种方法 及 C#调用C++编写的的COM DLL
- C#中get与set方法
- Delphi 调用C#编写的WebService 参数为Null解决方法
- C# 如何调用 Delphi 编写的 DLL 方法
- jQuery中使用getJSON方法调用C#的后台方法
- Delphi 调用C#编写的WebService 参数为Null解决方法
- c#中的get/set方法
- C++与C#编写的DLL/COM的各种调用方法
- com调用的几种方法 及 C#调用C++编写的的COM DLL
- Dephi调用C#编写的WebService的一些问题与解决方法
- Delphi 调用C#编写的WebService 参数为Null解决方法
- C# 使用 Environment.GetCommandLineArgs 方法 制作*.exe和参数 供其他程序调用
- C# 使用 Environment.GetCommandLineArgs 方法 制作*.exe和参数 供其他程序调用
- Delphi 调用C#编写的WebService 参数为Null解决方法
- Delphi (c++builder) 调用C#编写的WebService 参数为Null解决方法