Skip to content

Instantly share code, notes, and snippets.


daleth90/Pet.cs Secret

Created Oct 20, 2018
What would you like to do?
public class Pet {
// name是private變數,Pet以外的物件無法直接取得此變數
private string name;
// Pet類別的建構函式,參數是name
// 以這種寫法來初始化物件內部的變數name
public Pet( string name ) { = name;
// 但可以透過public方法取得name的值
public string GetName() {
return name;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment