using System; namespace ConsoleApp23 { class Program { static void Main(string[] args) { Guid id = Guid.NewGuid(); Console.WriteLine(ObjectToString(id)); Console.Read(); } /// <summary> /// 根据对象输出字符串 /// </summary> /// <param name="obj">传入obj</param> /// <returns></returns> public static string ObjectToString(object obj) { return obj != null ? obj.ToString() : null; } } }