當前位置: 首頁>>代碼示例>>C#>>正文


C# String.Select方法代碼示例

本文整理匯總了C#中System.String.Select方法的典型用法代碼示例。如果您正苦於以下問題:C# String.Select方法的具體用法?C# String.Select怎麽用?C# String.Select使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.String的用法示例。


在下文中一共展示了String.Select方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: IsChaveAcessoValida

        /// <summary>
        /// Valida a Chave de Acesso de um documento fiscal.
        /// </summary>
        /// <param name="chaveAcesso">Chave de Acesso</param>
        /// <returns>verdadeiro caso a Chave de Acesso seja valida, false caso contrário.</returns>
        public static Boolean IsChaveAcessoValida(String chaveAcesso)
        {
            if (String.IsNullOrWhiteSpace(chaveAcesso) || chaveAcesso.Length != 44)
            {
                return false;
            }
            if (!Regex.IsMatch(chaveAcesso, @"^\d{44}$"))
            {
                return false;
            }

            int[] digitos = chaveAcesso.Select(x => int.Parse(x.ToString())).ToArray();
            int soma = 0, dv, m;

            for (int i = digitos.Length - 2; i >= 0; )
            {
                for (int p = 2; p <= 9 && i >= 0; p++, i--)
                {
                    soma += digitos[i] * p;
                }
            }

            m = (soma % 11);
            dv = m <= 1 ? 0 : dv = 11 - m;

            return dv == digitos.Last();
        }
開發者ID:cleciobarbosa,項目名稱:NFeSharp,代碼行數:32,代碼來源:Utils.cs

示例2: SelectProperty

        public void SelectProperty(string name, Button openPopupWithThis)
        {
            var parentWindow = Web.PortalDriver.Title;
            Wait.Until(d => openPopupWithThis.Exists);
            openPopupWithThis.AsyncClick();
            Thread.Sleep(2000);
            PopUpWindow.SwitchTo(Title);

            // Switch to the frame within this popup dialog
            Web.PortalDriver.SwitchTo()
                .Frame(Web.PortalDriver.FindElement(By.Id("ifrmAttributeTable")));
            Wait.Until(d => new Container(By.Id("spanAttributeName")).Exists);

            var parsedName = name.Split('.');
            var path = new String[parsedName.Length - 1];
            Array.Copy(parsedName, path, parsedName.Length - 1);
            var propertyName = parsedName.Last();

            foreach (var expander in path.Select(attr => new Button(By.XPath(String.Format("//*[@id='spanAttributeName' and text()='{0}']/../../td[1]/a", attr))))) {
                expander.Click();
            }

            var property = new Container(By.XPath(String.Format("//*[@id='spanAttributeName' and text()='{0}']", propertyName)));
            property.Click();

            // Switch back out of frame
            PopUpWindow.SwitchTo(Title);
            OkButton.Click();
            PopUpWindow.SwitchTo(parentWindow);
        }
開發者ID:PortalAutomation,項目名稱:Portal-Selenium-Framework,代碼行數:30,代碼來源:SelectPropertyModalPopup.cs

示例3: Matches

            public bool Matches(String str)
            { 
                var chars = str.Distinct().Select(x => x.ToString()).ToList();
                Dictionary<string, Boolean> mapping = new Dictionary<string, bool>();
                
                mapping.Add(chars[0], true);
                mapping.Add(chars[1], false);

                var match = str.Select(x => mapping[x.ToString()]).Zip(BooleanPattern, (x, y) => x == y).All(x => x==true);
                if (match)
                    return true;
                mapping.Clear();
                mapping.Add(chars[0], false);
                mapping.Add(chars[1], true);
                match = str.Select(x => mapping[x.ToString()]).Zip(BooleanPattern, (x, y) => x == y).All(x => x == true);
                return match;
            }
開發者ID:cookies8710,項目名稱:Dojo7000,代碼行數:17,代碼來源:Program.cs

示例4: GetQualifiedValues

 public JsonResult GetQualifiedValues(String part, String locale, String[] keys)
 {
     if (!_context.DebugMode)
         throw new Exception("Unauthorized: DebugMode not on.");
     var values = keys == null
         ? Enumerable.Empty<FlattenedQualifiedValue>()
         : keys.Select(key => new FlattenedQualifiedValue(_context.Repository.GetQualified(new Qualifier.Unique(Part.Parse(part), new Locale(locale), key))));
     return Json(new { Success = true, Values = values }, JsonRequestBehavior.AllowGet);
 }
開發者ID:BackseatDevelopers,項目名稱:BLocal,代碼行數:9,代碼來源:MvcLocalizationController.cs

示例5: TransformSpecialCase

        internal static string TransformSpecialCase(IRow theRow, short redLightDiviser, short numberOfLightsOn)
        {
            var lightsOn = new String('\0', numberOfLightsOn);
            lightsOn = String.Join("", lightsOn.Select((light, index) => 
                    CheckIfIsTimeToUseRed(index, redLightDiviser) 
                        ? BerlinClockConstants.RedLight : BerlinClockConstants.YellowLight));

            return AppendLightsOffAndLineBreak(theRow.NumberOfLights, lightsOn, theRow.HasLineBreak);
        }
開發者ID:gomeswes,項目名稱:DotNetBerlinClock,代碼行數:9,代碼來源:LightsTransformer.cs

示例6: ComputeCrcHash

        public uint ComputeCrcHash(String input)
        {
            Byte[] bytes = input.Select(c => (byte) c).ToArray();
            uint crc = bytes.Aggregate(0xffffffff, (current, b) => (current >> 8) ^ CrcTable[(current ^ b) & 0xff]);

            crc = crc ^ 0xffffffff;

            return crc;
        }
開發者ID:raynjamin,項目名稱:Imgix-CSharp,代碼行數:9,代碼來源:Crc32.cs

示例7: reconstructMessage

        public static String reconstructMessage(String s, int k)
        {
            var r = s.GroupBy(x => x)
                .Select(x => new KeyValuePair<int, char>(x.Count(), x.First()))
                .Aggregate(
                    new {
                        pr = new KeyValuePair<int, char>(0, '0'),
                        alphabet = "abcdefghijklmnopqrstuvwxyz"
                    },
                    (seed, x) => {
                        if (s.Count() - x.Key == k)
                            return new { pr = x, alphabet = String.Join("", seed.alphabet.Except(new String(x.Value, 1))) };
                        return new { pr = seed.pr, alphabet = String.Join("", seed.alphabet.Except(new String(x.Value, 1))) };
                });

            if (r.pr.Key != 0) return String.Join("", s.Select(x => new String(r.pr.Value, 1)));

            return String.Join("", s.Select(x => new String(r.alphabet.First(), 1)));;
        }
開發者ID:snowyunee,項目名稱:rx_study,代碼行數:19,代碼來源:week11.cs

示例8: Main

        static void Main(string[] args)
        {
            while (true)
            {
                // sleeps 10 milliseconds not to eat out cpu time
                Thread.Sleep(10);
                String action = Console.ReadLine().Trim();

                switch (action)
                {
                    case "ready?":
                        Console.WriteLine("ready!");
                        Console.Out.Flush();
                        break;
                    case "generate code":
                        // makes a list of 25 dots, converts one of them in a sharp, splits the string in
                        //  5 tokens of 5 characters each
                        List<char> row = new String('.', 25).ToCharArray().ToList();
                        row[new Random().Next(24)] = '#';
                        List<string> rows = new List<string>();

                        for (int i = 0; i < 5; i++)
                            rows.Add(string.Join("", row.Select(c => c.ToString())
                                                        .Skip(i*5)
                                                        .Take(5)
                                                        .ToArray()));
                        foreach (string s in rows)
                        {
                            Console.WriteLine(s);
                            Console.Out.Flush();
                        }
                        break;
                    case "find code":
                        List<string> code = new List<string>();
                        for (int i = 0; i < 5; i++)
                            code.Add(Console.ReadLine());
                        for (int y = 0; y < 5; y++)
                        {
                            int x = code[y].IndexOf('#');
                            if (x != -1)
                            {
                                Console.WriteLine("{0} {1}", x, y);
                                Console.Out.Flush();
                            }
                        }
                        break;
                    case "bye!":
                                Console.WriteLine("bye!");
                                Console.Out.Flush();
                                System.Environment.Exit(0);
                        break;
                }

            }
        }
開發者ID:pistacchio,項目名稱:StreamConnection,代碼行數:55,代碼來源:csharpbot.cs

示例9: set_x

 static String[] set_x(String[] board, Char c)
 {
     bool changed = false;
     return board
         .Select(xs =>
             String.Join("", xs.Select(x =>
            {
                if (changed == false && x == '?')
                {
                    changed = true;
                    return c;
                }
                return x;
            }))
          )
          .ToArray();
 }
開發者ID:snowyunee,項目名稱:rx_study,代碼行數:17,代碼來源:week10.cs

示例10: SelectProperty

        public void SelectProperty(string name)
        {
            // Switch to the frame within this popup dialog
            Web.PortalDriver.SwitchTo()
                .Frame(Web.PortalDriver.FindElement(By.Id("ifrmAttributeTable")));
            Wait.Until(d => new Container(By.Id("spanAttributeName")).Exists);

            var parsedName = name.Split('.');
            var path = new String[parsedName.Length - 1];
            Array.Copy(parsedName, path, parsedName.Length - 1);
            //var propertyName = parsedName.Last();

            foreach (var expander in path.Select(attr => new Button(By.XPath(String.Format("//*[@id='spanAttributeName' and text()='{0}']/../../td[1]/a", attr))))) {
                expander.Click();
            }

            var property = new Container(By.XPath(String.Format("//*[@id='spanQualifiedAttributeDisplayName' and text()='{0}']/../span", name)));
            property.Click();
            Web.PortalDriver.SwitchTo().DefaultContent();
        }
開發者ID:PortalAutomation,項目名稱:Portal-Selenium-Framework,代碼行數:20,代碼來源:SelectPropertyPopup.cs

示例11: _SearchResults

		[OutputCache(CacheProfile = "NoCacheProfile")] // TODO: Can't we just vary cache by parameter, when does it crawl ?
        public ActionResult _SearchResults(String searchTerm, String[] sources, String[] refiners, Int32 iDisplayLength = 10, Int32 iDisplayStart = 0)
        {
            Dictionary<String, String> srcs = null;
            if (sources != null && sources.Length > 0)
            {
                srcs = sources.Select(src => src.Split(':')).ToDictionary(defs => defs[0], defs => defs[1]);
            }

            Dictionary<String, String> refs = null;
            if (refiners != null && refiners.Length > 0)
            {
                var rs = refiners.Select(r => new Tuple<String, String>(r.Split(new Char[] { ':' })[0], r.Split(new Char[] { ':' })[1]))
                    .GroupBy(r => r.Item1);
                refs = rs.ToDictionary(g => g.Key, g => g.Select(t => t.Item2).Aggregate((a, b) => a + "," + b));
            }

            var searchContent = _businessModule.GetSearchResults(searchTerm, srcs, refs, iDisplayStart, iDisplayLength);

            return PartialView(searchContent);
        }
開發者ID:Eugene-Murray,項目名稱:Contract_Validus,代碼行數:21,代碼來源:SearchController.cs

示例12: luhnCheck

 // Luhn Check methods (http://rosettacode.org/wiki/Luhn_test_of_credit_card_numbers#C.23)
 private static bool luhnCheck(String cardNumber)
 {
     return luhnCheck(cardNumber.Select(c => c - '0').ToArray());
 }
開發者ID:nccgroup,項目名稱:memscan,代碼行數:5,代碼來源:Program.cs

示例13: Map

 public void Map(String typeName, String[] queueName)
 {
     _typeNames.Add(typeName);
     _typeNamesMap.Add(typeName, queueName.Select(name => new QueueName(name)).ToArray());
 }
開發者ID:paralect,項目名稱:Paralect.ServiceBus,代碼行數:5,代碼來源:EndpointsMapping.cs

示例14: GetPitches

 private PitchType[] GetPitches(String pitches)
 {
     return pitches.Select(p => GetPitchType(p)).ToArray();
 }
開發者ID:DavidHoerster,項目名稱:Agile.EventedBaseball,代碼行數:4,代碼來源:PlayGameRecord.cs

示例15: Main

        /// <summary>
        /// Entry point - pass "verbose" as a command-line
        /// argument to initialize Embree in verbose mode.
        /// </summary>
        public static int Main(String[] args)
        {
            try
            {
                var verbose = (args.Select(s => s.ToLower()).Contains("verbose"));
                if (verbose) args.Select(s => s != "verbose"); // Clean up arglist
                ParseCommandLineArguments(args); // For selecting ray packet sizes

                if (verbose)
                {
                    Console.WriteLine("Embree.NET Benchmark [VERBOSE]");
                    Console.WriteLine("==============================");
                    RTC.Register("verbose=999"); // max verbosity?
                }
                else
                {
                    Console.WriteLine("Embree.NET Benchmark");
                    Console.WriteLine("====================");
                }

                Console.WriteLine(""); // this is for debugging
                Console.WriteLine("[+] " + Bits + "-bit mode.");

                // Note this is similar to the original Embree benchmark program
                Console.WriteLine("[+] Performance indicators are per-thread.");

                {
                    // Benchmark parameters
                    int w = 1024, h = 1024;

                    Console.WriteLine("[+] Benchmarking intersection queries.");

                    foreach (var item in Benchmarks.Intersections(SceneFlags.Static, Flags, 501, w, h))
                        Measure(item.Item2, item.Item3, (s) => Console.WriteLine("    {0} = {1}", item.Item1.PadRight(35), s));

                    Console.WriteLine("[+] Benchmarking occlusion queries.");

                    foreach (var item in Benchmarks.Occlusions(SceneFlags.Static, Flags, 501, w, h))
                        Measure(item.Item2, item.Item3, (s) => Console.WriteLine("    {0} = {1}", item.Item1.PadRight(35), s));
                }

                /*{
                    Console.WriteLine("[+] Benchmarking geometry manipulations.");

                    foreach (var item in Benchmarks.Geometries(SceneFlags.Static, Flags))
                        Measure(item.Item2, item.Item3, (s) => Console.WriteLine("    {0} = {1}", item.Item1.PadRight(35), s));
                }*/

                if (verbose)
                    RTC.Unregister();

                return EXIT_SUCCESS;
            }
            catch (Exception e)
            {
                var msg = e is AggregateException ? e.InnerException.Message : e.Message;
                Console.WriteLine(String.Format("[!] Error: {0}.", msg));
                Console.WriteLine("\n========= STACK TRACE =========\n");
                Console.WriteLine(e.StackTrace);
                return EXIT_FAILURE;
            }
        }
開發者ID:TomCrypto,項目名稱:Embree.NET,代碼行數:66,代碼來源:Program.cs


注:本文中的System.String.Select方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。