如何将类的公共属性写入文本文件? [英] How Do I Write Public Properties From A Class To A Textfile?
本文介绍了如何将类的公共属性写入文本文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将一个类的公共属性写入文本文件,但我不会为什么工作?
这是我的代码:
Hi,
I am trying to write public properties form a class to a textfile but i wont work why?
This is my code :
Type getPublicPropertiesType = (typeof(IOffer));
PropertyInfo[] myPropertyInfo = getPublicPropertiesType.GetProperties(BindingFlags.Public | BindingFlags.Instance);
StreamWriter log;
if (!File.Exists("logg.txt"))
{
log = new StreamWriter("logg.txt");
}
else
{
log = File.AppendText("logg.txt");
}
log.WriteLine("The number of public properties is {0}.", myPropertyInfo.Length);
log.Close();
推荐答案
这篇关于如何将类的公共属性写入文本文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文