using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Dynamic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp2 { class Program { static void Main(string[] args) { dynamic mileageObj = new ExpandoObject(); mileageObj.userName = "李斯"; mileageObj.userAge = 23; for (int i = 1; i <= 5; i++) { (mileageObj as ICollection<KeyValuePair<string, object>>).Add(new KeyValuePair<string, object>("動態屬性" + i, "動態屬性" + i)); } Console.WriteLine(JsonConvert.SerializeObject(mileageObj)); Console.ReadLine(); } } }