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


C# String.Count方法代码示例

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


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

示例1: parseFileToDataSet

 //This will parse the data to a Data Set
 public void parseFileToDataSet(String filePath, data textDatabase, data textDatabaseView, String day)
 {
     //This function is a test function to parse items into a dataset.
     String[] FileLines = System.IO.File.ReadAllLines(filePath); // This will store all the lines of the file into a string array
     foreach (String line in FileLines)
     {
         int tabCount = 0; // reset the tabCount
         String[] temp = new String[tabCount];
         // here we will resize the array depending on the tabCount
         temp = line.Split('\t');
         if (temp.Count() < 16 && temp.Count() != 1)
         {
             temp = (String[])resizeArray(temp); // in some lines in the text file, the last field is sometimes incomplete and without a tab character.
         }
         if (temp[0].Equals("Day") || temp[0].Equals("") || temp[0].StartsWith("The") || temp[0].StartsWith("***") )  // this won't add the first row which contains the headings.
             Console.WriteLine();  // just a stupid step
         else
         {
             textDatabase.addRow(temp, textDatabase);
             if(temp[0].Equals(day))  // and if it belongs to the day from the KML file, we'll use that.
             {
                 //Check if this is the day before the day we want
                 textDatabaseView.addRow(temp, textDatabaseView);  // This will add the parsed data as a row in the database. //But this will add only the days for this KML file
             }
         }
     }
 }
开发者ID:mtswiss,项目名称:UniWork,代码行数:28,代码来源:Parser.cs

示例2: sigConfigServer

        public sigConfigServer(String[] args)
        {
            // Initialise variables and check commandline arguments for values (for manual specific logging)
            InitializeComponent();
            this.AutoLog = false;
            sigConfigServerServiceLog = new System.Diagnostics.EventLog();
            string logSource = "sigConfigServerSource";
            string logName = "sigConfigServerLog";

            if (args.Count() > 0)
            {
                logSource = args[0];
            }
            if (args.Count() > 1)
            {
                logSource = args[1];
            }

            if (!System.Diagnostics.EventLog.SourceExists(logSource))
            {
                System.Diagnostics.EventLog.CreateEventSource(logSource, logName);
            }

            sigConfigServerServiceLog.Source = logSource;
            sigConfigServerServiceLog.Log = logName;

            // Logging
            sigConfigServerServiceLog.WriteEntry("Roswell Email Signature Sync service (server mode) created.");

            this.OnStart();
        }
开发者ID:probablytom,项目名称:sigConfig,代码行数:31,代码来源:SigConfigServer.cs

示例3: Config

        public Config(String[] args)
        {
            if (args.Count() == 1 && args[0] == "/?")
            {
                Banners.About();
                throw new ConfigurationErrorsException(String.Empty);
            }
            else
            {
                if (args.LastOrDefault() == "/verbose")
                {
                    IsVerbose = true;
                    args = args.Take(args.Count() - 1).ToArray();
                }

                if (args.Count() != 3)
                {
                    throw new ConfigurationErrorsException("Expected three arguments as explained below.");
                }
                else
                {
                    ProjectFile = Path.GetFullPath(args[0]);
                    if (IsVerbose) Console.WriteLine("Resolved %ProjectFile as {0}.", ProjectFile.ToTrace());
                    if (!File.Exists(ProjectFile))
                    {
                        throw new ConfigurationErrorsException(String.Format(
                            "%ProjectFile (specified as \"{0}\") does not exist.", ProjectFile.ToTrace()));
                    }

                    ProjectDir = Path.GetDirectoryName(ProjectFile);
                    if (IsVerbose) Console.WriteLine("Resolved %ProjectDir as {0}.", ProjectDir.ToTrace());

                    TemplateFile = Path.GetFullPath(args[1]);
                    if (IsVerbose) Console.WriteLine("Resolved %TemplateFile as {0}.", TemplateFile.ToTrace());
                    if (!File.Exists(TemplateFile))
                    {
                        throw new ConfigurationErrorsException(String.Format(
                            "%TemplateFile (specified as \"{0}\") does not exist.", TemplateFile.ToTrace()));
                    }

                    DestinationFile = Path.GetFullPath(args[2]);
                    if (IsVerbose) Console.WriteLine("Resolved %DestinationFile as {0}.", DestinationFile.ToTrace());
                    if (!File.Exists(DestinationFile))
                    {
                        if (IsVerbose) Console.WriteLine("Destination file doesn't exist at {0}. Creating it...", DestinationFile.ToTrace());

                        var destinationDir = Path.GetDirectoryName(DestinationFile);
                        if (!Directory.Exists(destinationDir))
                        {
                            if (IsVerbose) Console.WriteLine("Destination file directory doesn't exist at {0}. Creating it...", destinationDir.ToTrace());
                            Directory.CreateDirectory(destinationDir);
                            if (IsVerbose) Console.WriteLine("Destination file directory successfully created at {0}.", destinationDir.ToTrace());
                        }

                        File.WriteAllText(DestinationFile, String.Empty);
                        if (IsVerbose) Console.WriteLine("Destination file successfully created at {0}.", DestinationFile.ToTrace());
                    }
                }
            }
        }
开发者ID:xeno-by,项目名称:autoversioner,代码行数:60,代码来源:Config.cs

示例4: GenerateChoices

        private String[] GenerateChoices(
            String [] names)
        {
            String [] choices = new String[names.Count()];

             for (int i = 0; i < names.Count(); i++)
               { choices[i] = names[i]; }

             return choices;
        }
开发者ID:noxdafox,项目名称:clips,代码行数:10,代码来源:WineFormsExample.cs

示例5: equals

 public static String equals(String s, String t)
 {
     var lcm = LCM(s.Count(), t.Count());
     //var r = Enumerable.SequenceEqual(
     //    Enumerable.Repeat(s, (lcm / s.Count())).SelectMany(l => l),
     //    Enumerable.Repeat(t, (lcm / t.Count())).SelectMany(l => l));
     return (Enumerable.Repeat(s, (lcm / s.Count())).SelectMany(l => l)
         .SequenceEqual(Enumerable.Repeat(t, (lcm / t.Count())).SelectMany(l => l))) ?
         "Equal" : "Not Equal";
 }
开发者ID:snowyunee,项目名称:rx_study,代码行数:10,代码来源:week13.cs

示例6: ConcatenateAll

 /* Concatenate all the strings in an array into one single string. */
 public static String ConcatenateAll(String seperator, String[] texts)
 {
     if (texts.Count() == 0)
         return "";
     var sb = new StringBuilder(texts[0]);
     for (int i = 1; i < texts.Count(); i++ )
     {
         sb.Append(seperator + texts[i]);
     }
     return sb.ToString();
 }
开发者ID:nkcsgexi,项目名称:GhostFactor2,代码行数:12,代码来源:StringUtil.cs

示例7: Alert

        public Alert(String Message, Window parentWindow, ConsoleColor backgroundColour, String Title)
            : base(Title, 6, (Console.WindowWidth / 2) - 25, 50, 5 + (int)Math.Ceiling(((Double)Message.Count() / textLength)), parentWindow)
        {
            BackgroundColour = backgroundColour;

            Create(Message, parentWindow);
        }
开发者ID:wizardbeard,项目名称:ConsoleDraw,代码行数:7,代码来源:Alert.cs

示例8: Create

        private void Create(String Message, Window parentWindow)
        {
            var count = 0;
            while ((count*45) < Message.Count())
            {
                var splitMessage = Message.PadRight(textLength * (count + 1), ' ').Substring((count * textLength), textLength);
                var messageLabel = new Label(splitMessage, PostionX + 2 + count, PostionY + 2, "messageLabel", this);
                Inputs.Add(messageLabel);

                count++;
            }

            /*
            var messageLabel = new Label(Message, PostionX + 2, PostionY + 2, "messageLabel", this);
            messageLabel.BackgroundColour = BackgroundColour;*/

            okBtn = new Button(PostionX + Height - 2, PostionY + 2, "OK", "OkBtn", this);
            okBtn.Action = delegate() { ExitWindow(); };

            Inputs.Add(okBtn);

            CurrentlySelected = okBtn;

            Draw();
            MainLoop();
        }
开发者ID:wizardbeard,项目名称:ConsoleDraw,代码行数:26,代码来源:Alert.cs

示例9: Login

        public ActionResult Login(UsuarioModel usuario)
        {
            if (ModelState.IsValid)
            {
                var servico = ModuleBuilder.CriarServicoAutenticacao();

                var usuarioAutentiado = servico.AutenticacarUsuario(usuario.Email, usuario.Senha);

                if (usuarioAutentiado != null)
                {
                    String[] permicoes = new String[2];

                    foreach (var permissao in usuarioAutentiado.Permissoes)
                    {
                        permicoes[permicoes.Count(t => t != null)] = permissao.Texto;
                    }

                    var logado = new UsuarioLogado(usuarioAutentiado.Email, permicoes);
                    FormsAuthentication.SetAuthCookie(logado.Email, true);
                    Session["USUARIO_LOGADO"] = logado;
                    return RedirectToAction("Index", "Home");
                }
            }

            ModelState.AddModelError("INVALID_LOGIN", "Usuário ou senha inválidos.");
            return View("Index", usuario);
        }
开发者ID:ericgottschalk,项目名称:crescer-2015-2,代码行数:27,代码来源:LoginController.cs

示例10: Button

 public Button(int x, int y, String text, String iD, Window parentWindow)
     : base(x, y, 1, text.Count() + 2, parentWindow, iD)
 {
     Text = text;
     BackgroundColour = parentWindow.BackgroundColour;
     Selectable = true;
 }
开发者ID:wizardbeard,项目名称:ConsoleDraw,代码行数:7,代码来源:Button.cs

示例11: isChinese

 public static bool isChinese(String str)
 {
     for (int i = 0; i < str.Count(); i++)
         if (!isChinese(str[i]))
             return false;
     return true;
 }
开发者ID:xiangyustudy,项目名称:WeiboEntityDistinguish,代码行数:7,代码来源:StringUtil.cs

示例12: Label

 public Label(int x, int y, String text, String id, Window parentWindow)
     : base(x, y, 1, text.Count(), parentWindow, id)
 {
     Text = text;
     BackgroundColour = parentWindow.BackgroundColor;
     IsSelectable = false;
 }
开发者ID:CaseyMcCordAnderson,项目名称:TextUI,代码行数:7,代码来源:Label.cs

示例13: Create

        private void Create(String Message, TuiWindow parentTuiWindow)
        {
            var count = 0;
            while ((count * 45) < Message.Count())
            {
                var splitMessage = Message.PadRight(textLength * (count + 1), ' ').Substring((count * textLength), textLength);
                var messageLabel = new TuiLabel(splitMessage, X + 2 + count, Y + 2, "messageLabel", this);
                AddControl(messageLabel);

                count++;
            }

            okBtn = new TuiButton(X + Height - 2, Y + 2, "OK", "OkBtn", this);
            okBtn.Action = delegate() { Result = true; Close(); };

            cancelBtn = new TuiButton(X + Height - 2, Y + 8, "Cancel", "cancelBtn", this);
            cancelBtn.Action = delegate() { Close(); };

            AddControl(okBtn);
            AddControl(cancelBtn);

            CurrentlySelected = okBtn;

            Draw();
        }
开发者ID:CaseyMcCordAnderson,项目名称:TextUI,代码行数:25,代码来源:TuiConfirm.cs

示例14: TuiConfirm

        public TuiConfirm(String Message, TuiWindow parentTuiWindow, ConsoleColor backgroundColor, String Title = "Message")
            : base(Title, 6, (Console.WindowWidth / 2) - 25, 50, 5 + (int)Math.Ceiling(((Double)Message.Count() / textLength)), parentTuiWindow)
        {
            BackgroundColor = backgroundColor;

            Create(Message, parentTuiWindow);
        }
开发者ID:CaseyMcCordAnderson,项目名称:TextUI,代码行数:7,代码来源:TuiConfirm.cs

示例15: SongButton

        public SongButton(Rectangle rect, String folder)
        {
            String[] songfiles = Directory.GetFiles(folder, "*.wav", SearchOption.TopDirectoryOnly);
            String[] dmlfiles = Directory.GetFiles(folder, "*.dml", SearchOption.TopDirectoryOnly);

            if (dmlfiles.Count() > 0)
                dmlfile = dmlfiles[0];

            String[] pngs = Directory.GetFiles(folder, "*.png", SearchOption.TopDirectoryOnly);//gets images from folder
            String[] jpgs = Directory.GetFiles(folder, "*.jpg", SearchOption.TopDirectoryOnly);
            String[] images = new String[pngs.Length + jpgs.Length];
            pngs.CopyTo(images, 0);
            jpgs.CopyTo(images, pngs.Length);
            if (images.Count() > 0)
            {
                String image = images[0];
                texture = Texture2D.FromStream(Globals.graphics.GraphicsDevice, File.OpenRead(image));//reads images from stream(non content)
            }
            else
            {
                texture = new Texture2D(Globals.graphics.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
                texture.SetData<Color>(new Color[] { Color.White });
            }
            this.song = songfiles[0];
            if (songfiles.Length>0) this.music = new Wave(songfiles[0]);
            this.title = songfiles[0];
            this.rect = rect;
            CollisionMask = new RectCollider(rect);
        }
开发者ID:roflwaffl,项目名称:Phosphaze,代码行数:29,代码来源:SongButton.cs


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