当前位置: 首页>>代码示例>>C#>>正文


C# String.ToArray方法代码示例

本文整理汇总了C#中System.String.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# String.ToArray方法的具体用法?C# String.ToArray怎么用?C# String.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.String的用法示例。


在下文中一共展示了String.ToArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EncryptCode

 // 加密
 public String EncryptCode(String number)
 {
     char[] arrStr = number.ToArray();
     for (int i = 0; i < arrStr.Length; i++)
     {
         arrStr[i] = (char)((arrStr[i] - 41) % 10 + 48);
     }
     return new String(arrStr);
 }
开发者ID:SunningPig,项目名称:CreateQRCode,代码行数:10,代码来源:EncryptAndDecode.cs

示例2: StringScore

 public static int StringScore(String s)
 {
     int sum = 0;
     foreach (var c in s.ToArray())
     {
         sum += (int)(c - 64);
     }
     return sum;
 }
开发者ID:Kafiil,项目名称:ProjectEulerSolutions,代码行数:9,代码来源:P22.cs

示例3: reverseString

 //Method to reverse the order of the characters in strings.
 public static String reverseString(String s)
 {
     //Change string to character array
     char[] reverse = s.ToArray();
     //Reverse the array
     Array.Reverse(reverse);
     //Return reversed array as string
     return new String(reverse);
 }
开发者ID:derrick-burns,项目名称:07_08_2015_Lab,代码行数:10,代码来源:Program.cs

示例4: ChiffrerDechiffrer

 //Une Fonction pour chiffrer et Déchiffrer
 public static String ChiffrerDechiffrer(String str, int Value)
 {
     //Tableau char utiliser pour faire le ou sur chaque lettre ou chiffre
     Char[] carry = str.ToArray();
     //Boucle qui applique le ou exclusife sur chaque character
     for (int i = 0; i < str.Length; i++)
     {
         carry[i] ^= (char)Value;
     }
     return new string(carry);
 }
开发者ID:Balnian,项目名称:Client_Serveur_TP1,代码行数:12,代码来源:Class1.cs

示例5: reverseNumber

        public static String reverseNumber(String number)
        {
            char[] numberAsArray = number.ToArray();
            int numberLength = numberAsArray.Length - 1;
            String reverseNumber = null;

            for(int i = numberLength; i >= 0; i--){
                reverseNumber += numberAsArray[i];
            }

            return reverseNumber;
        }
开发者ID:jotem,项目名称:SPOJ,代码行数:12,代码来源:Peter.cs

示例6: isUnique_withSort

        //method 4: sort string first, then check 2 neighbour chars if same
        static bool isUnique_withSort(String s)
        {
            if (s.Length > 128) return false;
            Array charArray = s.ToArray<Char>();
            Array.Sort(charArray);
            StringBuilder sb = new StringBuilder();
            foreach (Char c in charArray) {
                sb.Append(c);
            }
            s = sb.ToString();

            for (int i = 0; i < (s.Length-1); i++) {
                if (s[i] == s[i + 1])
                    return false;
            }

            return true;
        }
开发者ID:yellowheartsue,项目名称:cc189_cSharp,代码行数:19,代码来源:isUnique.cs

示例7: convertToUnicode

        private static StringBuilder convertToUnicode(String regText)
        {
            char[] chars = regText.ToArray();
            StringBuilder hexString = new StringBuilder();
            for (int i = 0; i < chars.Length; i++)
            {
                String iniHexString = String.Format("{0:X}", chars[i]);// ((int)HexEncoding.GetByteCount((int)chars[i])).ToString(); 
                if (iniHexString.Length == 1)
                    iniHexString = "000" + iniHexString;
                else if (iniHexString.Length == 2)
                    iniHexString = "00" + iniHexString;
                else if (iniHexString.Length == 3)
                    iniHexString = "0" + iniHexString;

                hexString.Append(iniHexString);
            }

            return hexString;
        }
开发者ID:har9421,项目名称:BestSeller,代码行数:19,代码来源:BL_SMSNotification.cs

示例8: isPalindrome

        public static Boolean isPalindrome(String number)
        {
            char[] numberAsArray = number.ToArray();
            int arrayLength = numberAsArray.Length;
            int numberLength = arrayLength-1;
            double halfOfArrayLength = ((arrayLength) / 2);
            int halfOfArrayLengthCeilled = (int)Math.Ceiling(halfOfArrayLength);

            for (int i = 0; i < halfOfArrayLengthCeilled; i++, numberLength--)
            {
                if(!isSameNumber(numberAsArray[i], numberAsArray[numberLength])){
                    return false;
                }

                if(isMoreThanHalfChecked(numberLength, i))
                {
                    break;
                }
            }

            return true;
        }
开发者ID:jotem,项目名称:SPOJ,代码行数:22,代码来源:Peter.cs

示例9: GetInterViews

        public static IList<InterView> GetInterViews(String[] ids)
        {
            try
            {
                MongoCursor<InterView> mc = MongoDBHelper.GetCursor<InterView>(
                    "InterView",
                    Query.EQ("_id", new BsonArray(ids.ToArray())),
                    new SortByDocument("CreatedTime", 1),
                    0,
                    0);

                List<InterView> objs = new List<InterView>();
                objs.AddRange(mc);

                return objs;
            }
            catch (System.Exception err)
            {
                throw new CBB.ExceptionHelper.OperationException(
                    CBB.ExceptionHelper.ErrType.SystemErr,
                    CBB.ExceptionHelper.ErrNo.DBOperationError,
                    err);
            }
        }
开发者ID:dkme,项目名称:moooyo,代码行数:24,代码来源:InterViewProvider.cs

示例10: AddUser_Click

        private void AddUser_Click(object sender, RoutedEventArgs e)
        {
            // Username
            String username = _Username.GetLineText(0);
            // Email
            String email = _Email.GetLineText(0);
            // Home
            String home = _Home.GetLineText(0);
            // list? Read? Write? Delete?
            Boolean list = (Boolean)_List.IsChecked;
            Boolean read = (Boolean)_Read.IsChecked;
            Boolean write = (Boolean)_Write.IsChecked;
            Boolean delete = (Boolean)_Delete.IsChecked;
            // Password
            String password = _Password.GetLineText(0);
            // Name
            String name = _Name.GetLineText(0);
            // Role
            String role;

            try
            {
                role = _Role.SelectedValue.ToString();
            }
            catch (Exception)
            {
                role = "null";
            }
            // Expiration
            String expiration = _Expiration.GetLineText(0);
            // Groups
            String[] groups;

            try
            {
                groups = new String[_GroupRemove.Items.Count];
                int j = 0;
                foreach (ItemCollection i in _GroupRemove.Items)
                {
                    groups[j] = i.ToString();
                    j++;
                }
            }
            catch (Exception)
            {

                groups = null;
            }

            MessageBox.Show(String.Format("Username:{0}\nEmail:{1}\nHome:{2}\nList:{3}\nRead:{4}\nWrite:{5}\nDelete:{6}\nPassword:{7}\nName:{8}\nRole:{9}\nExpiration:{10}\nGroups:{11}\n", username, email, home, list, read, write
                , delete, password, name, role, expiration, groups.ToArray<String>().ToString()));
            this.Close();
        }
开发者ID:Carterj3,项目名称:SmartFile,代码行数:53,代码来源:AddUser.xaml.cs

示例11: SetupSeps

        /// <summary>
        /// 
        /// </summary>
        private void SetupSeps()
        {
            // seps should contain only characters present in alphabet; 
            seps = new String(seps.Intersect(alphabet.ToArray()).ToArray());

            // alphabet should not contain seps.
            alphabet = new String(alphabet.Except(seps.ToArray()).ToArray());

            seps = ConsistentShuffle(seps, salt);

            if (seps.Length == 0 || (alphabet.Length / seps.Length) > SEP_DIV)
            {
                var sepsLength = (int)Math.Ceiling(alphabet.Length / SEP_DIV);
                if (sepsLength == 1)
                    sepsLength = 2;

                if (sepsLength > seps.Length)
                {
                    var diff = sepsLength - seps.Length;
                    seps += alphabet.Substring(0, diff);
                    alphabet = alphabet.Substring(diff);
                }

                else seps = seps.Substring(0, sepsLength);
            }

            sepsRegex = new Regex(string.Concat("[", seps, "]"), RegexOptions.Compiled);
            alphabet = ConsistentShuffle(alphabet, salt);
        }
开发者ID:Ruberoid,项目名称:hashids.net,代码行数:32,代码来源:Hashids.cs

示例12: convertColorFromSeq

 //Creates hexadecimal color from sequence
 private Brush convertColorFromSeq(String s)
 {
     try
     {
         if (s.All(c => "actg".Contains(c)))
         {
             String color = "#";
             char[] array = s.ToArray();
             for (int i = 0; i < 4; i++)
             {
                 char c = char.ToLower(array[i]);
                 if (c == 'a') color += "99";
                 if (c == 'c') color += "bb";
                 if (c == 't') color += "dd";
                 if (c == 'g') color += "ff";
             }
             return (Brush)new BrushConverter().ConvertFromString(color); //To always ensure Opacity = 1, use i < 3 and initialize color = "#ff"
         }
         else { return Brushes.LightGray; }
     }
     catch (Exception exc) { 
         Console.WriteLine(exc);
         return Brushes.LightGray;
     }
 }
开发者ID:igemsoftware,项目名称:Wellesley_HCI_2012,代码行数:26,代码来源:Sites.xaml.cs

示例13: GetMethodIndex

        // var x = db.test().find().clone(...)
        // will return index just after 'find()'
        // where clone is the method name, and find() is the parent method
        private static int GetMethodIndex(Match firstBracket, String query, out bool hasParent)
        {
            //var word = new List<char>();
            var chars = query.ToArray<char>();
            hasParent = false;

            int i;

            for (i = firstBracket.Index - 1; i > -1; i--)
            {
                var c = chars[i];

                if (c == ']' || c == '}' || c == ')')
                {
                    hasParent = true;
                    return i + 1;
                }

                if (Char.IsLetter(c) || Char.IsNumber(c)
                    || Char.IsWhiteSpace(c) || c == '.' || c == '_')
                {
                    continue;
                }
                else
                {
                    break;
                }
            }
            return i + 1;
        }
开发者ID:stan-github-,项目名称:MongoUI,代码行数:33,代码来源:ObjectChainParser.cs

示例14: GetInterestIdArrWenWenSorted

 /// <summary>
 /// 按兴趣编号数组获取兴趣问问按指定字段排序
 /// </summary>
 /// <param name="interestsids">兴趣编号数组</param>
 /// <param name="sortByField">排序字段</param>
 /// <param name="lift">升或降序</param>
 /// <param name="pagesize">每页条数</param>
 /// <param name="pageno">当前页</param>
 /// <returns></returns>
 private static IList<WenWen> GetInterestIdArrWenWenSorted(String[] interestsids, String sortByField, int lift, int pagesize, int pageno)
 {
     MongoCursor<WenWen> mc = MongoDBHelper.GetCursor<WenWen>(WenWen.GetCollectionName(), Query.In("InterestID", new BsonArray(interestsids.ToArray())), new SortByDocument(sortByField, lift), pageno, pagesize);
     List<WenWen> objs = new List<WenWen>();
     objs.AddRange(mc);
     IList<WenWen> wenwens = new List<WenWen>();
     foreach (var obj in objs)
     {
         obj.AnswerCount = GetWenWenAnswer(obj.ID, 0, 0, 1).Count;
         wenwens.Add(obj);
     }
     return wenwens;
 }
开发者ID:dkme,项目名称:moooyo,代码行数:22,代码来源:WenWenProvider.cs

示例15: GetMethodName

        private static String GetMethodName(Match firstBracket, String s)
        {
            var word = new List<char>();
            var chars = s.ToArray<char>();

            for (int i = firstBracket.Groups[0].Index - 1; i > -1; i--)
            {
                var c = chars[i];
                if (Char.IsLetter(c) || Char.IsNumber(c)
                    || Char.IsWhiteSpace(c) || c == '.')
                {
                    word.Add(c);
                }
                else
                {
                    break;
                }
            }

            var Word = new StringBuilder();
            word.Reverse();
            word.ForEach(x => Word.Append(x.ToString()));

            return Word.ToString().Trim();
        }
开发者ID:stan-github-,项目名称:MongoUI,代码行数:25,代码来源:Program.cs


注:本文中的System.String.ToArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。