C# dönüyor (Ben bütün alana özgü şeyler çıkardı ve hala boş bir dizi döndürür): yanaBu yansıma kodunda ne var? GetFields() İşte</p> <p>2.0 kod boş bir dizi Net
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
ChildClass cc = new ChildClass();
cc.OtherProperty = 1;
FieldInfo[] fi = cc.GetType().GetFields();
Console.WriteLine(fi.Length);
Console.ReadLine();
}
}
class BaseClass<T>
{
private int myVar;
public int MyProperty
{
get { return myVar; }
set { myVar = value; }
}
}
class ChildClass : BaseClass<ChildClass>
{
private int myVar;
public int OtherProperty
{
get { return myVar; }
set { myVar = value; }
}
}
}
+1 Bu, Örneklemeyi ve NonPublic'i belirtmeniz gerekir. –
Cevabı alkış! Bunu anlamakta sorun yaşıyorum. Birisi Özel Alanlar için NonPublic ile birlikte neden Statnce veya Static gerektiğini açıklayabilir mi? – Zack
@ rory.ap: Evet, tam olarak. –