04 2023 档案
摘要:一.声明一个MyClass对象 public class MyClass { public int MyField; } 二.获取RequiredAttribute类型信息 MyClass instance = new MyClass(); FieldInfo field = instance.Ge
阅读全文
摘要:void M(object o1, object o2) { var t = (o1, o2); if (t is (int, string)) {} // test if o1 is an int and o2 is a string switch (o1) { case int: break;
阅读全文
摘要:如果标记了[NonSerialized]特性,会防止将该字段序列化。但是,该字段仍然可以用于foreach迭代,因为它仍然是枚举的有效成员。如果要防止特定枚举成员被foreach迭代,用[NonSerialized]特性是不起作用的。相反,可以创建一个自定义的Attribute继承自System.A
阅读全文
摘要:调用表达式 () 使用括号 () 调用()或调用委托。 以下示例演示如何在使用或不使用参数的情况下调用方法,以及调用委托: Action<int> display = s => Console.WriteLine(s); var numbers = new List<int>(); numbers.
阅读全文
摘要:实例一: JsonSerializerSettings jsonSettings = new JsonSerializerSettings { DateFormatString = "yyyy-MM-dd HH:mm:ss.fff", }; Model model = new Model { Cre
阅读全文
摘要:一.下面是一个示例代码,该代码使用iTextSharp将多个PDF文件合并为一个: public static void MergePDFs(string[] pdfPaths, string outputPath) { using (FileStream stream = new FileStre
阅读全文
摘要:1.创建一个新的WinForms或WPF应用程序,具体取决于您的需要。 2.将Telerik Reporting组件添加到您的应用程序中。您可以通过NuGet包管理器来完成此操作。 3.在您的应用程序中添加多个报表文件。您可以使用Telerik Report Designer创建报表并将其添加到您的
阅读全文