public override string ToString() { StringBuilder sb = new StringBuilder("PooledBooking("); sb.Append("NumPax: "); sb.Append(NumPax); sb.Append(",StartTime: "); sb.Append(StartTime); sb.Append(",Src: "); sb.Append(Src == null ? "<null>" : Src.ToString()); sb.Append(",Dst: "); sb.Append(Dst == null ? "<null>" : Dst.ToString()); sb.Append(")"); return(sb.ToString()); }
public void search() { Src v1 = Src.SESHP; Tgt v2 = Tgt.SMONEYC; Console.WriteLine("--- original"); Console.WriteLine("v1: " + v1 + ", " + v1.ToString("x") + ", {0:x}", (int)v1); Console.WriteLine("v2: " + v2 + ", " + v2.ToString("x") + ", {0:x}", (int)v2); Console.WriteLine("--- by Parse"); v2 = (Tgt)Enum.Parse(typeof(Src), v1.ToString()); Console.WriteLine("v1: " + v1 + ", " + v1.ToString("x") + ", {0:x}", (int)v1); Console.WriteLine("v2: " + v2 + ", " + v2.ToString("x") + ", {0:x}", (int)v2); v2 = Tgt.SMONEYC; Console.WriteLine(Environment.NewLine + "--- original"); Console.WriteLine("v1: " + v1 + ", " + v1.ToString("x") + ", {0:x}", (int)v1); Console.WriteLine("v2: " + v2 + ", " + v2.ToString("x") + ", {0:x}", (int)v2); Console.WriteLine("--- by TryParse"); Enum.TryParse <Tgt>(v1.ToString(), true, out v2); Console.WriteLine("v1: " + v1 + ", " + v1.ToString("x") + ", {0:x}", (int)v1); Console.WriteLine("v2: " + v2 + ", " + v2.ToString("x") + ", {0:x}", (int)v2); }