C#结构函数
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Demo { struct CustomerName { public string firstName, lastName; public string Name() { return firstName+" "+lastName; } } class Program { static void Main(string[] args) { CustomerName myCustomer; myCustomer.firstName = "Ji"; myCustomer.lastName = "Qing"; Console.WriteLine("客户的名字:{0}", myCustomer.Name()); Console.ReadKey(); } } } 结构struct函数,有意思。可以尝试利用这个特性。 本文转自TBHacker博客园...