// Must have write permissions to the path folder PdfWriter writer = new PdfWriter(@"demo.pdf"); PdfDocument pdf = new PdfDocument(writer); Document document = new Document(pdf); Paragraph header = new Paragraph("標題 HEADER") .SetFont(sysFont) .SetTextAlignment(TextAlignment.CENTER) .SetFontSize(20);
using System; using System.Collections.Generic; using System.Text;
namespaceUnitTestProject { publicinterfaceIFoo { Bar Bar { get; set; } string Name { get; set; } int Value { get; set; } boolDoSomething(stringvalue); }
using System; using System.Collections; using System.Collections.Generic; using System.Linq;
namespace DeferredExec { class Program { private static void Main(string[] args) { var people = GetPeople(); var names = people .Where(person => person.Age > 18) .Select(person => person.Name);
foreach (var name in names) { Console.WriteLine(name); } }
private static IEnumerable<Person> GetPeople() { yield return new Person { Id = 1, Name = "John", Age = 36 }; yield return new Person { Id = 2, Name = "Bill", Age = 6 }; yield return new Person { Id = 3, Name = "Steve", Age = 23 }; }
public class Person {
private int _id; private string _name; private int _age; public int Id { get { return _id; } set { _id = value; } }
public string Name { get { return _name; } set { _name = value; } } public int Age { get { return _age; } set { _age = value; } } } } }
public class User { private string _name;// _name為欄位 public string Name // Name為屬性,它含有程式碼塊 { get { // 可以在此添加額外會影響的私有變數 return _name;// 讀取(返回_name值) } set { _name = value;// 為_name賦值 // 可以在此添加額外會影響的私有變數 } } }