所属分类:
多国语言处理
开发工具:C#
文件大小:4KB
下载次数:4
上传日期:2008-05-22 14:56:42
说明: AutomaticPropertiesDefaultValues
Article_src.zip
PropertyInfo[] props = o.GetType().GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static)
for (int i = 0 i < props.Length i++)
{
PropertyInfo prop = props[i]
if (prop.GetCustomAttributes(true).Length > 0)
{
object[] defaultValueAttribute = prop.GetCustomAttributes(typeof(DefaultValueAttribute), true)
if (defaultValueAttribute != null)
{
DefaultValueAttribute dva = defaultValueAttribute[0] as DefaultValueAttribute
if(dva != null)
prop.SetValue(o, dva.Value, null)
}
文件列表:
AutomaticPropertiesDefaultValues
................................\AutomaticPropertiesDefaultValues.csproj
................................\Program.cs
................................\Properties
................................\..........\AssemblyInfo.cs
AutomaticPropertiesDefaultValues.sln