我知道抽象類中的構造函數應該在C#中受到保護。 但有些抽象類不需要的非參數構造函數。例如: public abstract MyAbstractClass {
public abstract Method1();
public abstract Method2();
// non-parameterless constructors are not needed
}
對於controling結構成員和力量程序員使用的getter/setter函數,我想寫這樣的代碼如下模式: /* Header file: point.h */
...
/* define a struct without full struct definition. */
struct point;
/* getter/setter functions. */
int point
我有以下類: public class Person
{
public String Name { get; set; }
}
我有取入Person和方法的String作爲參數: public void ChangeName(Person p, String name)
{
p.Name = name;
}
由於Person通過引用傳遞,應該改變的所述Name通