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


C# String.Any方法代码示例

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


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

示例1: isStrongPassword

        /*
         * Validates that password is a strong password
         * Conditions:
         *      Special characters not allowed
         *      Spaces not allowed
         *      At least one number character
         *      At least one capital character
         *      Between 6 to 12 characters in length
         */
        public static bool isStrongPassword(String password)
        {
            // Check for null
            if (password == null)
                return false;

            // Minimum and Maximum Length of field - 6 to 12 Characters
            if (password.Length < passwordLowerBoundary || password.Length > passwordUpperBoundary)
                return false;

            // Special Characters - Not Allowed
            // Spaces - Not Allowed
            if (!(password.All(c => char.IsLetterOrDigit(c))))
                return false;

            // Numeric Character - At least one character
            if (!password.Any(c => char.IsNumber(c)))
                return false;

            // At least one Capital Letter
            if (!password.Any(c => char.IsUpper(c)))
                return false;

            return true;
        }
开发者ID:purdue-cs-groups,项目名称:cs307-project01,代码行数:34,代码来源:InputValidator.cs

示例2: IsPasswordCompliant

 public bool IsPasswordCompliant(String password)
 {
     bool isCompliant = false;
     if(password.Length>=8 && password.Any(char.IsDigit) && password.Any(char.IsUpper) && password.Any(char.IsLower))
     {
         isCompliant = true;
     }
     return isCompliant;
 }
开发者ID:izzach,项目名称:CSharp,代码行数:9,代码来源:Subscriber.cs

示例3: ArchiveGenerationParameters

        /// <summary>
        /// Initializes a new instance of the <see cref="ArchiveGenerationParameters"/> class.
        /// </summary>
        /// <param name="args">The application's command line arguments.</param>
        public ArchiveGenerationParameters(String[] args)
        {
            if (args == null || !args.Any())
                throw new InvalidCommandLineException();

            var parser = new CommandLineParser(args);
            if (!parser.IsParameter(args.First()))
                throw new InvalidCommandLineException();

            switch (args.First().ToLowerInvariant())
            {
                case "-pack":
                    Command = ArchiveGenerationCommand.Pack;
                    ProcessPackParameters(args, parser);
                    break;

                case "-list":
                    Command = ArchiveGenerationCommand.List;
                    ProcessListParameters(args, parser);
                    break;

                default:
                    throw new InvalidCommandLineException();
            }
        }
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:29,代码来源:ArchiveGenerationParameters.cs

示例4: FontGenerationParameters

        /// <summary>
        /// Initializes a new instance of the <see cref="FontGenerationParameters"/> class.
        /// </summary>
        /// <param name="args">The application's command line arguments.</param>
        public FontGenerationParameters(String[] args)
        {
            if (args == null || !args.Any())
                throw new InvalidCommandLineException();

            var parser = new CommandLineParser(args.Skip(1));
            if (parser.IsParameter(args.First()))
            {
                throw new InvalidCommandLineException();
            }

            NoBold   = parser.HasArgument("nobold");
            NoItalic = parser.HasArgument("noitalic");

            FontName = args.First();
            FontSize = parser.GetArgumentOrDefault<Single>("fontsize", 16f);
            Overhang = parser.GetArgumentOrDefault<Int32>("overhang", 0);
            PadLeft = parser.GetArgumentOrDefault<Int32>("pad-left", 0);
            PadRight = parser.GetArgumentOrDefault<Int32>("pad-right", 0);
            SuperSamplingFactor = parser.GetArgumentOrDefault<Int32>("supersample", 2);

            if (SuperSamplingFactor < 1)
                SuperSamplingFactor = 1;

            SourceText    = parser.GetArgumentOrDefault<String>("sourcetext");
            SourceFile    = parser.GetArgumentOrDefault<String>("sourcefile");
            SourceCulture = parser.GetArgumentOrDefault<String>("sourceculture");

            if (SourceText != null && SourceFile != null)
                throw new InvalidCommandLineException("Both a source text and a source file were specified. Pick one!");

            SubstitutionCharacter = parser.GetArgumentOrDefault<Char>("sub", '?');
        }
开发者ID:prshreshtha,项目名称:ultraviolet,代码行数:37,代码来源:FontGenerationParameters.cs

示例5: GetFiles

        public static List<SPFile> GetFiles(string webUrl, string libraryTitle, String[] extensions = null)
        {
            var context = new ClientContext(webUrl);
            var web = context.Web;

            var list = web.Lists.GetByTitle(libraryTitle);
            var files = list.RootFolder.Files;
            context.Load(files, fs => fs.Include(f => f.Name, f => f.ETag, f => f.ServerRelativeUrl, f => f.ListItemAllFields));
            context.ExecuteQuery();

            var items = new List<SPFile>();
            foreach (File file in files)
                if (extensions == null || extensions.Any(ext => file.Name.EndsWith(ext)))
                {
                    var listitem = file.ListItemAllFields;
                    items.Add(new SPFile()
                    {
                        Name = file.Name.Substring(0, file.Name.LastIndexOf('.')),
                        Extension = file.Name.Substring(file.Name.LastIndexOf('.')),
                        ETag = file.ETag,
                        RemoteUrl = new Uri(webUrl).Server() + file.ServerRelativeUrl,
                        Category = listitem.FieldValues.GetValue("Category")
                    });
                }
            return new List<SPFile>(items.OrderBy(f => f.Name));
        }
开发者ID:beachandbytes,项目名称:GorillaDocs,代码行数:26,代码来源:SPHelper.cs

示例6: Main

        private static Int32 Main(String[] args)
        {
            if (!args.Any())
            {
                var assemblyFileName = Path.GetFileName(
                    Assembly.GetEntryAssembly().Location
                );

                Console.Error.WriteLine($"Usage: {assemblyFileName} outputDirectory");
                return 2;
            }

            try
            {
                var writer = new SourceFileWriter(args[0]);

                foreach (var command in ShellployMetadata.GetCommands())
                {
                    Console.WriteLine($"Generating {command.ClassName}...");
                    var targetUnit = new CommandCodeGenerator(command)
                        .GenerateCompileUnit();
                    writer.Write(targetUnit);
                }

                Console.WriteLine("Done.");
                return 0;
            }
            catch (Exception exc)
            {
                Console.Error.WriteLine(exc);
                return 1;
            }
        }
开发者ID:NaseUkolyCZ,项目名称:HarshPoint,代码行数:33,代码来源:Program.cs

示例7: isValidPath

        bool isValidPath(String path)
        {
            if (path.Any(c => Path.GetInvalidPathChars().Contains(c)))
            {
                return (false);
            }

            return (Path.IsPathRooted(path));
        }
开发者ID:iejeecee,项目名称:mediaviewer,代码行数:9,代码来源:PathToFilenameConverter.cs

示例8: StatManager

        public StatManager(String SaveStatePath)
        {
            if (string.IsNullOrEmpty(SaveStatePath)) { logger.Error("SaveStatePath was null or empty."); throw new ArgumentNullException("SaveStatePath Can't be Null or Empty String. "); }
            if (SaveStatePath.LastIndexOfAny(Path.GetInvalidPathChars()) >= 0) { logger.Error("Invalid Path Characters In SaveStatePath=\"{0}\")", SaveStatePath); throw new ArgumentException("Invalid Characters In Path"); }
            if (SaveStatePath.Any( x => char.IsWhiteSpace ( x ))) { logger.Error("Whitespace Characters In SaveStatePath=\"{0}\" ", SaveStatePath); throw new ArgumentException("WhiteSpace Characters In Path"); }

            logger.Info("Called with (SaveStatePath=\"{0}\")", SaveStatePath);
            LoadSaveState(SaveStatePath);
            _savestatepath = SaveStatePath;
        }
开发者ID:Mhopkinsinc,项目名称:NHL94SaveStateReader,代码行数:10,代码来源:StatManager.cs

示例9: CalculateDyingYear

        public static int CalculateDyingYear(String name)
        {
            if (name.Any(x => !char.IsLetter(x)))
                throw new ArgumentException("name musst be a name");

            int result = 0;
            foreach (char c in name.ToLower())
            {
                result += c - 'a' + 1;
            }
            return result % 100;
        }
开发者ID:offbyoneprogrammer,项目名称:first_unit_test,代码行数:12,代码来源:DieYearCalculator.cs

示例10: AbstractVersionControlSystem

        /// <summary>
        /// Creates an instance of the version control system with the given filesystem and root.
        /// </summary>
        /// <param name="root">The root of the version control system, relative to the file system.</param>
        /// <param name="fileSystemAdaptee">The file system to perform IO operations on.</param>
        protected AbstractVersionControlSystem(String root, IFileSystem fileSystemAdaptee)
            : base(root, fileSystemAdaptee)
        {
            // Parse the root to make sure it ends with a path separator
            root = ((root.EndsWith(FileSystem.PathSeparator) || !root.Any()) ? String.Empty : FileSystem.PathSeparator);

            // Verify that the version dir exists
            var version = root + FileSystem.VERSION_DIR;

            if (!Exists(version))
            {
                CreateDirectory(version);
            }
        }
开发者ID:Yndal,项目名称:BDSA-Project-2012,代码行数:19,代码来源:AbstractVersionControlSystem.cs

示例11: Main

        static void Main(String[] args) {
            if (!args.Any()) {
                String src = @"
int printf(char *, ...);
int main(int argc, char **argv) {
    printf(""%d"", argc);
    return 0;
}
";
                Compiler compiler = Compiler.FromSource(src);
                Console.WriteLine(compiler.Assembly);
            } else {
                Compiler compiler = Compiler.FromFile(args[0]);
                Console.WriteLine(compiler.Assembly);
            }
        }
开发者ID:phisiart,项目名称:C-Compiler,代码行数:16,代码来源:Program.cs

示例12: GetColumns

        /// <summary>根据字段名数组获取字段数组</summary>
        /// <param name="table"></param>
        /// <param name="names"></param>
        /// <returns></returns>
        public static IDataColumn[] GetColumns(this IDataTable table, String[] names)
        {
            if (names == null || names.Length < 1) return null;

            //List<IDataColumn> list = new List<IDataColumn>();
            //foreach (String item in names)
            //{
            //    IDataColumn dc = table.GetColumn(item);
            //    if (dc != null) list.Add(dc);
            //}

            //if (list.Count < 1) return null;
            //return list.ToArray();

            return table.Columns.Where(c => names.Any(n => c.Is(n))).ToArray();
        }
开发者ID:windygu,项目名称:asxinyunet,代码行数:20,代码来源:ModelHelper.cs

示例13: ParseParameters

        private bool ParseParameters( String[] parameters, out string input_file, out string output_file )
        {
            input_file = null;
            output_file = null;

            //--help -help /help /? -?

            string general_help_str = "Saleae Serial Export txt to bin converter\n";
            general_help_str += "usage: thing.exe input_file output_file\n";

            var help_parameters = new string[] { "--help", "-help", "-h", "/?", "/help", "-?" };

            if( parameters.Any( x => help_parameters.Contains( x.ToLower() ) ) || parameters.Count() == 0 )
            {
                Console.WriteLine( general_help_str );
                return false;
            }

            if( parameters.Count() != 2 )
            {
                Console.WriteLine( "expected 2 parameters" );
                return false;
            }

            input_file = parameters[ 0 ];

            output_file = parameters[ 1 ];

            if( System.IO.File.Exists( input_file ) == false )
            {
                Console.WriteLine( "input file " + input_file + " does not exist" );
                return false;
            }

            string output_folder = new System.IO.FileInfo( output_file ).Directory.FullName;

            if( System.IO.Directory.Exists( output_folder ) == false )
            {
                Console.WriteLine( "output file directory " + output_folder + " does not exist" );
                return false;
            }

            return true;
        }
开发者ID:Marcus10110,项目名称:SaleaeUtilityCore,代码行数:44,代码来源:Program.cs

示例14: ContainsInvalidURLCharacters

 /// <summary>
 /// Does the URL contain invalid characters?
 /// </summary>
 /// <param name="url">The URL</param>
 /// <returns>True if the URL contains invalid characters.</returns>
 public static bool ContainsInvalidURLCharacters(String url)
 {
     return url.Any(ch => ch > 255);
 }
开发者ID:Romiko,项目名称:encog-dotnet-core,代码行数:9,代码来源:URLUtility.cs

示例15: IsTextExtension

 static Boolean IsTextExtension(String url)
 {
     String[] extensions = new String[] { "txt", "csv", "html", "htm" };
     return extensions.Any(x => url.EndsWith("." + x));
 }
开发者ID:NNSostack,项目名称:DataJuggling,代码行数:5,代码来源:CsvListRepository.cs


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