private bool MailGonder(string doktorAdi, string doktorSoyadi, string email, DateTime tarih, TimeSpan saat)
        {
            System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
            System.Globalization.TextInfo    textInfo    = cultureInfo.TextInfo;
            MailMessage ePosta = new MailMessage();

            ePosta.From = new MailAddress("*****@*****.**");
            ePosta.To.Add(email);
            ePosta.Subject = "Randevu Hakkında";
            ePosta.Body    = doktorAdi + " " + doktorSoyadi + " isimli doktordan " + tarih + " - " + saat + " tarihli randevunuz iptal edilmiştir.";

            SmtpClient smtp = new SmtpClient();

            // Gönderenin eposta giriş bilgileri
            smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "159654357456");
            smtp.Port        = 587;
            smtp.Host        = "smtp.gmail.com";
            smtp.EnableSsl   = true;
            object userState = ePosta;

            try
            {
                smtp.SendAsync(ePosta, (object)ePosta);
                return(true);
            }
            catch (SmtpException ex)
            {
                throw new SmtpException(ex.ToString());
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Convert a string to mixed case (first letter in every word is uppercase)
        /// </summary>
        /// <param name="str">String to change to title case</param>
        /// <returns>Title case formatted string</returns>
        public static string ToMixedCase(string str)
        {
            System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
            System.Globalization.TextInfo    textInfo    = cultureInfo.TextInfo;

            return(textInfo.ToTitleCase(str.ToLower()));
        }
Ejemplo n.º 3
0
        public static List <SelectListItem> GetYearList()
        {
            System.Globalization.TextInfo ti = System.Globalization.CultureInfo.CurrentCulture.TextInfo;

            List <SelectListItem> list = new List <SelectListItem>();

            list.Add(new SelectListItem()
            {
                Text = "Select Year*", Value = ""
            });

            try
            {
                for (int i = DateTime.Now.Year - 1; i <= 2025; i++)
                {
                    list.Add(new SelectListItem()
                    {
                        Text = i.ToString(), Value = i.ToString()
                    });
                }
            }
            catch (Exception)
            { }

            return(list);
        }
        public ActionResult SendMail(string ad, string mail, string konu, string mesaj)
        {
            System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
            System.Globalization.TextInfo    textInfo    = cultureInfo.TextInfo;
            string isim    = textInfo.ToTitleCase(ad);
            string email   = textInfo.ToTitleCase(mail);
            string subject = textInfo.ToTitleCase(konu);
            string message = textInfo.ToTitleCase(mesaj);

            MailMessage ePosta = new MailMessage();

            ePosta.From = new MailAddress("*****@*****.**");
            ePosta.To.Add("*****@*****.**");
            ePosta.Subject = subject;
            ePosta.Body    = isim + " [" + email + "] " + "adlı üyeden mesaj;"
                             + Environment.NewLine
                             + Environment.NewLine
                             + message;
            SmtpClient smtp = new SmtpClient();

            smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "159654357456");
            smtp.Port        = 587;
            smtp.Host        = "smtp.gmail.com";
            smtp.EnableSsl   = true;
            object userState = ePosta;

            smtp.Send(ePosta);
            return(RedirectToAction("Index", "Home"));
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            var s = ReadLine();

            System.Globalization.TextInfo ti =
                System.Globalization.CultureInfo.CurrentCulture.TextInfo;
            WriteLine(ti.ToTitleCase(s));
        }
Ejemplo n.º 6
0
        private void startByLE(string path, string command)
        {
            if (!File.Exists(string.Format("{0}\\LocaleEmulator.dll", System.Environment.CurrentDirectory)) || !File.Exists(string.Format("{0}\\LoaderDll.dll", System.Environment.CurrentDirectory)))
            {
                MessageBox.Show("程式檢測到您當前運行的系統非繁體語係,但是非繁體語係啟動遊戲需要的檔案丟失,請嘗試重新下載。");
                return;
            }

            int CHINESEBIG5_CHARSET = 136;
            var commandLine         = string.Empty;

            commandLine = path.StartsWith("\"")
                ? $"{path} "
                : $"\"{path}\" ";
            commandLine += command;
            System.Globalization.TextInfo culInfo = System.Globalization.CultureInfo.GetCultureInfo("zh-HK").TextInfo;

            var l = new LEProc.LoaderWrapper
            {
                ApplicationName   = path,
                CommandLine       = commandLine,
                CurrentDirectory  = Path.GetDirectoryName(path),
                AnsiCodePage      = (uint)culInfo.ANSICodePage,
                OemCodePage       = (uint)culInfo.OEMCodePage,
                LocaleID          = (uint)culInfo.LCID,
                DefaultCharset    = (uint)CHINESEBIG5_CHARSET,
                HookUILanguageAPI = (uint)0,
                Timezone          = "China Standard Time",
                NumberOfRegistryRedirectionEntries = 0,
                DebugMode = false
            };

            uint ret;

            if ((ret = l.Start()) != 0)
            {
                if (ret == 0xC00700C1)
                {
                    MessageBox.Show($"非繁體語係系統啟動遊戲失敗\r\n"
                                    + $"錯誤碼: {Convert.ToString(ret, 16).ToUpper()}\r\n"
                                    + "導致這個錯誤的原因可能是因為使用了遊戲的自動更新,導致遊戲損壞了。\r\n"
                                    );
                }
                else
                {
                    MessageBox.Show($"非繁體語係系統啟動遊戲失敗\r\n"
                                    + $"錯誤碼: {Convert.ToString(ret, 16).ToUpper()}\r\n"
                                    + $"{string.Format($"{Environment.OSVersion} {(Is64BitOS() ? "x64" : "x86")}", Environment.OSVersion, Is64BitOS() ? "x64" : "x86")}\r\n"
                                    + $"{GenerateSystemDllVersionList()}\r\n"
                                    + "如果你有運行任何防毒軟體, 請關閉後再次嘗試。\r\n"
                                    + "如果仍然顯示此視窗, 請嘗試以「安全模式」啟動程式。"
                                    + "如果你進行了以上的嘗試仍然沒有一個有效,請隨時在後面的連結提交問題\r\n"
                                    + "https://github.com/xupefei/Locale-Emulator/issues\r\n" + "\r\n" + "\r\n"
                                    + "你可以按 CTRL+C 將此訊息複製到你的剪貼板。\r\n"
                                    );
                }
            }
        }
        public void sendMail(Request request)
        {
            MailMessage mail = new MailMessage
            {
                IsBodyHtml = true               //mail içeriğinde html etiketleri kullanılsın mı?
            };                                  //yeni bir mail nesnesi Oluşturuldu.

            mail.To.Add(request.user.userMail); //Kime mail gönderilecek.

            //mail kimden geliyor, hangi ifade görünsün?

            Setting setting = _siparisTakipDB.Settings.SingleOrDefault();

            mail.From    = new MailAddress(request.user.userMail, "Talebiniz Onaylandı", System.Text.Encoding.UTF8);
            mail.Subject = "Talebiniz Onaylandı";//mailin konusu

            System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
            System.Globalization.TextInfo    textInfo    = cultureInfo.TextInfo;
            string KullaniciAdSoyad = textInfo.ToTitleCase(request.user.userName) + " " + textInfo.ToTitleCase(request.user.userSurname);

            //mailin içeriği.. Bu alan isteğe göre genişletilip daraltılabilir.
            string text = "<span style='color: #28a745'><strong>Onaylandı</strong></span>";

            mail.Body = "<div style='color:black'>" +
                        "<p><strong> Müşteri Adı Soyadı: </strong><span id = 'userName' > " + KullaniciAdSoyad + " </span ></p>" +
                        "<p><strong> Talep No: </strong> <span id = 'requestDeliveryDate' >" + request.requestNo + "</span ></p>" +
                        "<p><strong> Talep Tarihi: </strong> <span id = 'requestDeliveryDate' >" + request.requestDeliveryDate + "</span ></p>" +
                        "<p><strong> Talep Eden Departman: </strong><span id = 'requestDepartment' >" + request.requestDepartment + "</span ></p>" +
                        "<p><strong> Talep Eden Personel: </strong><span id = 'requestSteff' >" + request.requestSteff + "</span ></p>" +
                        "<p><strong> Açıklama: </strong><span id = 'requestDescription' >" + request.requestDescription + "</span ></p>" +
                        "<p><strong> Tahmini Fiyat: </strong><span id = 'requestEstimatedPrice' >" + request.requestEstimatedPrice + "</span ></p>" +
                        "<p><strong> Gider Yeri: </strong><span id = 'requestExpensePlace' > " + request.requestExpensePlace + " </span ></p>" +
                        "<p><strong> Ürün Özellikleri: </strong><span id = 'requestProductFeatures' > " + request.requestProductFeatures + " </span ></p>" +
                        "<p><strong> Proje: </strong><span id = 'requestProject' > " + request.requestProject + " </span ></p>" +
                        "<p><strong> Miktar: </strong><span id = 'requestQuantity' > " + request.requestQuantity + " </span ></p>" +
                        "<p><strong> Durum: </strong><span id = 'requestStatus' > " + text + " </span ></p>" +
                        "<p><strong> Cinsi: </strong><span id = 'requestSpecies' >" + request.requestSpecies + "</span ></p>" +
                        "<p><strong> Tedarik Firma 1: </strong><span id = 'requestSupplyCompany1' >" + request.requestSupplyCompany1 + "</span ></p>" +
                        "<p><strong> Tedarik Firma 2: </strong><span id = 'requestSupplyCompany2' > " + request.requestSupplyCompany2 + " </span ></p>" +
                        "<p><strong> Tedarik Firma 3: </strong><span id = 'requestSupplyCompany3' > " + request.requestSupplyCompany3 + " </span ></p>" +
                        "</div>";
            mail.IsBodyHtml = true;
            SmtpClient smp = new SmtpClient();


            try
            {
                //mailin gönderileceği adres ve şifresi
                smp.Credentials = new NetworkCredential(setting.settingEPosta, setting.settingPassword);
                smp.Port        = setting.settingSmtpPort;
                smp.Host        = setting.settingSmtpHost; //gmail üzerinden gönderiliyor.
                smp.EnableSsl   = setting.settingSmtpSSL;
                smp.Send(mail);                            //mail isimli mail gönderiliyor.
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 8
0
 public static string ToTitleCase(this String str)
 {
     if (!String.IsNullOrEmpty(str))
     {
         System.Globalization.TextInfo txtInfo = System.Globalization.CultureInfo.CurrentCulture.TextInfo;
         return(txtInfo.ToTitleCase(str.ToLower()));
     }
     return(str);
 }
Ejemplo n.º 9
0
        public static string ToCapitalize(string inputString)
        {
            System.Globalization.CultureInfo cultureInfo =

                System.Threading.Thread.CurrentThread.CurrentCulture;

            System.Globalization.TextInfo textInfo = cultureInfo.TextInfo;

            return(textInfo.ToTitleCase(inputString.ToLower()));
        }
Ejemplo n.º 10
0
 private void MenuItemEditTextSentenceCase_Click(object sender, EventArgs e)
 {
     System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
     System.Globalization.TextInfo    ti          = cultureInfo.TextInfo;
     if (Document.SelectedText.Length == 0)
     {
         Document.SelectAll();
     }
     Document.SelectedText = ti.ToTitleCase(Document.SelectedText);
 }
Ejemplo n.º 11
0
        private String formatCamelCaseText(String camelCaseText)
        {
            //split name by camel case
            String formattedName = Regex.Replace(camelCaseText, "(\\B[A-Z]+?(?=[A-Z][^A-Z])|\\B[A-Z]+?(?=[^A-Z]))", " $1").Trim();

            System.Globalization.TextInfo ti = System.Globalization.CultureInfo.CurrentCulture.TextInfo;
            formattedName = ti.ToTitleCase(formattedName);

            return(formattedName);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// "tHiS is a sTring TesT" -> "This Is A String Test"
        /// Credits: http://extensionmethod.net/csharp/string/topropercase
        /// </summary>
        public static string ToProperCase(this string text)
        {
#if NETFX_CORE
            Debug.Assert(false, "not implemented yet");
            return("");
#else
            System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
            System.Globalization.TextInfo    textInfo    = cultureInfo.TextInfo;
            return(textInfo.ToTitleCase(text));
#endif
        }
Ejemplo n.º 13
0
        internal CultureInfo(string cultureName, string textAndCompareCultureName)
        {
            if (cultureName == null)
            {
                throw new ArgumentNullException("cultureName", Environment.GetResourceString("ArgumentNull_String"));
            }
            this.m_cultureTableRecord = CultureTableRecord.GetCultureTableRecord(cultureName, false);
            this.cultureID            = this.m_cultureTableRecord.ActualCultureID;
            this.m_name = this.m_cultureTableRecord.ActualName;
            CultureInfo cultureInfo = GetCultureInfo(textAndCompareCultureName);

            this.compareInfo = cultureInfo.CompareInfo;
            this.textInfo    = cultureInfo.TextInfo;
        }
Ejemplo n.º 14
0
 // İlk harfkeri büyütme fonksiyonu
 public string IlkHarfleriBuyut(string metin)
 {
     try
     {
         System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
         System.Globalization.TextInfo    textInfo    = cultureInfo.TextInfo;
         return(textInfo.ToTitleCase(metin));
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message, "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return("");
     }
 }
Ejemplo n.º 15
0
        public static string ConvertFirstLetterToUpper(string s)
        {
            try
            {
                System.Globalization.CultureInfo c = new System.Globalization.CultureInfo("en-us", false);
                System.Globalization.TextInfo    t = c.TextInfo;

                return(t.ToTitleCase(s));
            }
            catch (Exception ex)
            {
                Log.WriteToErrorLogFile(ex);
                return(null);
            }
        }
Ejemplo n.º 16
0
        public static string ToTitleCase(this string mText)
        {
            if (string.IsNullOrEmpty(mText))
            {
                return(mText);
            }

            System.Globalization.CultureInfo cultureInfo =
                System.Threading.Thread.CurrentThread.
                CurrentCulture;
            System.Globalization.TextInfo textInfo =
                cultureInfo.TextInfo;

            return(textInfo.ToTitleCase(mText.ToLower()));
        }
Ejemplo n.º 17
0
 public static string ToTitleCase(this string _S, string _sCulture = "tr-TR")
 {
     if (!String.IsNullOrEmpty(_S))
     {
         _S = _S.Trim();
         if (_S.Length > 0)
         {
             System.Globalization.CultureInfo cultureInfo = new System.Globalization.CultureInfo(_sCulture);
             System.Globalization.TextInfo    textInfo    = cultureInfo.TextInfo;
             _S = textInfo.ToLower(_S);
             _S = textInfo.ToTitleCase(_S);
         }
     }
     return(_S);
 }
        public static string IlkHarfleriBuyut(string metin)
        {
            string Degisen = "";

            try
            {
                System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
                System.Globalization.TextInfo    textInfo    = cultureInfo.TextInfo;
                Degisen = textInfo.ToTitleCase(metin);
            }
            catch (Exception e)
            {
                Degisen = metin;
            }
            return(Degisen);
        }
Ejemplo n.º 19
0
        public bool Kaydet(LogTablo log)
        {
            if (log.IslemIcerik != null)
            {
                System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
                System.Globalization.TextInfo    textInfo    = cultureInfo.TextInfo;
                log.IslemIcerik = textInfo.ToTitleCase(log.IslemIcerik);
            }
            db.LogTablo.Add(log);
            if (db.SaveChanges() > 0)
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 20
0
        public static string ToTitleCase(string mText)
        {
            string rText = "";

            try
            {
                System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
                System.Globalization.TextInfo    TextInfo    = cultureInfo.TextInfo;
                rText = TextInfo.ToTitleCase(mText);
            }
            catch
            {
                rText = mText;
            }
            return(rText);
        }
        /// <summary>
        /// Capitalize the first letter of the name
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        internal static string ToTitleCase(string name)
        {
            string fixedName = "";

            try
            {
                System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
                System.Globalization.TextInfo    TextInfo    = cultureInfo.TextInfo;
                fixedName = TextInfo.ToTitleCase(name);
            }
            catch
            {
                fixedName = name;
            }
            return(fixedName);
        }
Ejemplo n.º 22
0
        //-------------------------------------------------
        //Use for textbox : thousand separator //
        // Dont Use : incompleted code

        /*
         * public string ToSeparatorText(string strText, string chrCommaOrDot)
         * {
         *   string str = strText;
         *   str = str.Replace(chrCommaOrDot, "");
         *   int len = str.Length;
         *
         *
         *       while (len > 3)
         *       {
         *
         *            str = str.Insert(len - 3, chrCommaOrDot);
         *           len = len - 3;
         *
         *        }
         *
         *   return str ;
         * }
         *
         */

        //----------------------------------------------


        /// <summary>
        /// Convert a Unicode string to NameCase ( Title Case) By Le Nho Man
        /// Trimming Included
        /// </summary>
        /// <param name="Name">Unicode string to convert </param>
        /// <returns></returns>
        public static string ToNameCase(string Name)
        {
            string strTemp = Name.ToLower().Trim();

            while (strTemp.IndexOf("  ") != -1)       //Contains 2 continued space characters
            {
                strTemp = strTemp.Replace("  ", " "); // Replace 2 spaces by 1 space
            }

            System.Globalization.CultureInfo cultureInfo =

                System.Threading.Thread.CurrentThread.CurrentCulture;

            System.Globalization.TextInfo textInfo = cultureInfo.TextInfo;

            return(textInfo.ToTitleCase(strTemp.ToLower()));
        }
Ejemplo n.º 23
0
 private Shipment setUpper(Shipment ship)
 {
     System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
     System.Globalization.TextInfo    textInfo    = cultureInfo.TextInfo;
     ship.BillOfLading  = textInfo.ToUpper(ship.BillOfLading);
     ship.VoyageNo      = textInfo.ToUpper(ship.VoyageNo);
     ship.Origin        = textInfo.ToUpper(ship.Origin);
     ship.DepShortName  = textInfo.ToUpper(ship.DepShortName);
     ship.DepVessel     = textInfo.ToUpper(ship.DepVessel);
     ship.DepContainer  = textInfo.ToUpper(ship.DepContainer);
     ship.Destination   = textInfo.ToUpper(ship.Destination);
     ship.DestShortName = textInfo.ToUpper(ship.DestShortName);
     ship.ArrVessel     = textInfo.ToUpper(ship.ArrVessel);
     ship.ArrContainer  = textInfo.ToUpper(ship.ArrContainer);
     ship.CreatedBy     = textInfo.ToUpper(ship.CreatedBy);
     return(ship);
 }
        internal CultureInfo(string cultureName, string textAndCompareCultureName)
        {
            this.cultureID = 0x7f;
            if (cultureName == null)
            {
                throw new ArgumentNullException("cultureName", Environment.GetResourceString("ArgumentNull_String"));
            }
            this.m_cultureData = CultureData.GetCultureData(cultureName, false);
            if (this.m_cultureData == null)
            {
                throw new CultureNotFoundException("cultureName", cultureName, Environment.GetResourceString("Argument_CultureNotSupported"));
            }
            this.m_name = this.m_cultureData.CultureName;
            CultureInfo cultureInfo = GetCultureInfo(textAndCompareCultureName);

            this.compareInfo = cultureInfo.CompareInfo;
            this.textInfo    = cultureInfo.TextInfo;
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Gets a value indicating whether the TextInfo object represents a writing system where text flows from right to left.
        /// </summary>
        /// <param name="textInfo">A TextInfo instance.</param>
        /// <returns>true if text flows from right to left; otherwise, false.</returns>
        public static bool IsRightToLeft(this System.Globalization.TextInfo textInfo)
        {
            if (textInfo == null)
            {
                throw new ArgumentNullException("textInfo");
            }

            switch (textInfo.CultureName)
            {
            case "ar-SA":
            case "fa-IR":
            case "he-IL":
                return(true);

            default:
                return(false);
            }
        }
Ejemplo n.º 26
0
        private string ChangeCase(string original, CaseType caseType)
        {
            bool fixUnits       = true;
            bool fixMultipliers = true;

            string units  = "mm,m";
            string result = original;

            switch (caseType)
            {
            case CaseType.Upper:
                result = original.ToUpper();
                break;

            case CaseType.Lower:
                result = original.ToLower();
                break;

            case CaseType.Title:
                System.Globalization.TextInfo textInfo = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo;
                result = textInfo.ToTitleCase(original.ToLower());
                break;

            case CaseType.Sentence:
                result = Utils.TextUtilities.SentenceCase(original);
                break;

            default:
                result = original;
                break;
            }

            if (fixUnits)
            {
                result = Utils.TextUtilities.FixUnits(result, units.Split(','));
            }
            if (fixMultipliers)
            {
                result = Utils.TextUtilities.FixMultiplier(result);
            }

            return(result);
        }
Ejemplo n.º 27
0
 public string ConvMaiuscula(string Input)
 {
     System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
     System.Globalization.TextInfo    textInfo    = cultureInfo.TextInfo;
     return(textInfo.ToTitleCase(Input.ToLower()));
 }
Ejemplo n.º 28
0
 private string StringFormat(string text)
 {
     System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
     System.Globalization.TextInfo    textInfo    = cultureInfo.TextInfo;
     return(textInfo.ToTitleCase(text));
 }
 internal CultureInfo(string cultureName, string textAndCompareCultureName)
 {
     this.cultureID = 0x7f;
     if (cultureName == null)
     {
         throw new ArgumentNullException("cultureName", Environment.GetResourceString("ArgumentNull_String"));
     }
     this.m_cultureData = CultureData.GetCultureData(cultureName, false);
     if (this.m_cultureData == null)
     {
         throw new CultureNotFoundException("cultureName", cultureName, Environment.GetResourceString("Argument_CultureNotSupported"));
     }
     this.m_name = this.m_cultureData.CultureName;
     CultureInfo cultureInfo = GetCultureInfo(textAndCompareCultureName);
     this.compareInfo = cultureInfo.CompareInfo;
     this.textInfo = cultureInfo.TextInfo;
 }
Ejemplo n.º 30
0
        public void Operations()
        {
            string strOriginal = "These functions will come handy";
            string strModified = String.Empty;

            //Iterate String
            foreach (char c in strOriginal)
            {
                Console.WriteLine(c.ToString());
            }

            //Split  a string
            char[]   delim  = { ' ' };
            string[] strArr = strOriginal.Split(delim);
            foreach (string s in strArr)
            {
                Console.WriteLine(s);
            }

            // only starting position specified
            strModified = strOriginal.Substring(25);
            Console.WriteLine(strModified);

            // starting position and length of string to be extracted specified
            strModified = strOriginal.Substring(20, 3);
            Console.WriteLine(strModified);

            // Single Dimensional String Array

            string[] strArrr = new string[3] {
                "string 1", "string 2", "string 3"
            };
            // Omit Size of Array
            string[] strArr1 = new string[] { "string 1", "string 2", "string 3" };
            // Omit new keyword
            string[] strArr2 = { "string 1", "string 2", "string 3" };

            // Multi Dimensional String Array

            string[,] strArr3 = new string[2, 2] {
                { "string 1", "string 2" }, { "string 3", "string 4" }
            };
            // Omit Size of Array
            string[,] strArr4 = new string[, ] {
                { "string 1", "string 2" }, { "string 3", "string 4" }
            };
            // Omit new keyword
            string[,] strArr5 = { { "string 1", "string 2" }, { "string 3", "string 4" } };

            //Reverse a string

            var ct = strOriginal.Reverse().ToArray();

            Console.WriteLine(ct);

            //String comparision
            string one = "Hello";
            string two = "hello";

            Console.WriteLine(one == two);
            //true or false is for case sensitive
            var a = string.Compare(one, two, true);

            //throws null reference exception if the string is empty
            //nsole.WriteLine(one.Equals(two));


            //Convert a string to char[](char array)
            char[] chArr = strOriginal.ToCharArray();

            //Char array to string
            strModified = new string(chArr);

            //Test if String is null or Zero Length
            bool check = String.IsNullOrEmpty(strOriginal);

            // Convert the Case of a String
            System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
            System.Globalization.TextInfo    textInfo    = cultureInfo.TextInfo;
            // Lower Case
            Console.WriteLine(textInfo.ToLower(strOriginal));
            // Upper Case
            Console.WriteLine(textInfo.ToUpper(strOriginal));
            // Proper Case
            Console.WriteLine(textInfo.ToTitleCase(strOriginal));

            //Count the occurrences of words in a String

            string animals = "Dog,Cat,Dog,Dog,Lion,Dog,Tiger,Cat";
            var    resul   = animals.Split(',')
                             //.GroupBy(x => (x != "Dog" && x != "Cat") ?  "Other" : x)
                             .GroupBy(x => x)
                             .Select(g => new { Pet = g.Key, Count = g.Count() });

            foreach (var item in resul)
            {
                Console.WriteLine(item.Pet + " " + item.Count);
            }

            //Insert characters inside a string
            strModified = strOriginal.Insert(26, "very ");


            //Replace characters in a String
            strModified = strOriginal.Replace("come handy", "be useful");
        }
Ejemplo n.º 31
0
 public static string ProperCase(this string sender)
 {
     System.Globalization.TextInfo TI = (new System.Globalization.CultureInfo("en-US", false)).TextInfo;
     return(TI.ToTitleCase(sender.ToLower()));
 }
Ejemplo n.º 32
0
 internal CultureInfo(string cultureName, string textAndCompareCultureName)
 {
     if (cultureName == null)
     {
         throw new ArgumentNullException("cultureName", Environment.GetResourceString("ArgumentNull_String"));
     }
     this.m_cultureTableRecord = CultureTableRecord.GetCultureTableRecord(cultureName, false);
     this.cultureID = this.m_cultureTableRecord.ActualCultureID;
     this.m_name = this.m_cultureTableRecord.ActualName;
     CultureInfo cultureInfo = GetCultureInfo(textAndCompareCultureName);
     this.compareInfo = cultureInfo.CompareInfo;
     this.textInfo = cultureInfo.TextInfo;
 }