本文介绍了如何将类的公共属性写入文本文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将一个类的公共属性写入文本文件,但我不会为什么工作? 这是我的代码:
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();
推荐答案
更多推荐
如何将类的公共属性写入文本文件?
发布评论