using System.Threading;
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
Reference: 如何強迫 .Net 應用程式輸出英文的例外訊息
using System.Threading;
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
internal static bool sendAndroidNotification(string message, string registrationID) { const String ClientLoginURL = @"https://www.google.com/accounts/ClientLogin"; const String C2DMServerURL = @"http://android.apis.google.com/c2dm/send"; string collapseKey = DateTime.Now.ToShortDateString(); String AuthTokenParams = @"accountType=GOOGLE&Email=" + Properties.Settings.Default.AndroidSenderEmail // your sender email + "&Passwd=" + Properties.Settings.Default.AndroidSenderPassword // your sender password + "&service=ac2dm"; string authToken = getAndroidAuthToken(ClientLoginURL, AuthTokenParams); Dictionary<string, string> data = new Dictionary<string, string>(); data.Add("data.msg", HttpUtility.UrlEncode(message)); // use UrlEncode() so that I can push messages other than English (like Chinese) return sendAndroidPushMessage(C2DMServerURL, registrationID, collapseKey, authToken, data); }
static string ByteArrayToString1(byte[] source) { StringBuilder sb = new StringBuilder(); foreach (byte item in source) { sb.AppendFormat("{0:x2}", item); } return sb.ToString(); } static string ByteArrayToString2(byte[] source) { return BitConverter.ToString(source).Replace("-", ""); } static string ByteArrayToString3(byte[] source) { // namespace: System.Runtime.Remoting.Metadata.W3cXsd2001 return new SoapHexBinary(source).ToString(); } static string ByteArrayToString4(byte[] source) { // works for .Net 4 only return String.Concat(Array.ConvertAll(source, x => x.ToString("X2"))); }
enum Week { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday }
foreach (Week item in Enum.GetValues(typeof(Week))) { //... }