本文整理汇总了C#中System.String.All方法的典型用法代码示例。如果您正苦于以下问题:C# String.All方法的具体用法?C# String.All怎么用?C# String.All使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.String
的用法示例。
在下文中一共展示了String.All方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseSize
public static Int64 ParseSize(String sizeString, Boolean defaultToBinaryPrefix)
{
if (sizeString.All(char.IsDigit))
{
return Int64.Parse(sizeString);
}
var match = ParseSizeRegex.Matches(sizeString);
if (match.Count != 0)
{
var value = Decimal.Parse(Regex.Replace(match[0].Groups["value"].Value, "\\,", ""), CultureInfo.InvariantCulture);
var unit = match[0].Groups["unit"].Value.ToLower();
switch (unit)
{
case "kb":
return ConvertToBytes(Convert.ToDouble(value), 1, defaultToBinaryPrefix);
case "mb":
return ConvertToBytes(Convert.ToDouble(value), 2, defaultToBinaryPrefix);
case "gb":
return ConvertToBytes(Convert.ToDouble(value), 3, defaultToBinaryPrefix);
case "kib":
return ConvertToBytes(Convert.ToDouble(value), 1, true);
case "mib":
return ConvertToBytes(Convert.ToDouble(value), 2, true);
case "gib":
return ConvertToBytes(Convert.ToDouble(value), 3, true);
default:
return (Int64)value;
}
}
return 0;
}
示例2: 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;
}
示例3: IsValidFolderName
public static bool IsValidFolderName( String name )
{
Contract.Requires( !String.IsNullOrWhiteSpace( name ) );
// check system names
if( String.IsNullOrWhiteSpace( name ) || name == "." || name == ".." )
{
return false;
}
// whitespace and the start or end not allowed
if( name[ 0 ] == WhiteSpace || name[ name.Length - 1 ] == WhiteSpace )
{
return false;
}
// max length
if( name.Length > QuickIOPath.MaxFolderNameLength )
{
return false;
}
// point at the beginning or at the end is not allowed
// windows would automatically remove the point at the end
if( name[ 0 ] == '.' || name[ name.Length - 1 ] == '.' )
{
return false;
}
return name.All( IsValidFolderChar );
}
示例4: ContainsInvalidFileNameChars
/// <summary>
/// Checks if passed string can be used as a filename or it contains
/// some invalid characters.
/// </summary>
/// <param name="source">A string to test.</param>
/// <returns><see langword="true"/> if string contains invalid characters.</returns>
public static Boolean ContainsInvalidFileNameChars(String source)
{
Contract.Requires(source != null);
Char[] chars = Path.GetInvalidFileNameChars();
Contract.Assert(chars != null);
return source.All(s => chars.All(c => s != c));
}
示例5: isValidYYMM
public static bool isValidYYMM(String s)
{
if (s.Length != 4)
return false;
if (!s.All(Char.IsDigit))
return false;
String mm = s.Substring(2, 2);
int month = int.Parse(mm);
if ((month < 1) || (month > 12))
return false;
return true;
}
示例6: Main
public static void Main(String[] args)
{
Contract.Requires(!ReferenceEquals(args, null));
Contract.Requires(args.All(s => !String.IsNullOrWhiteSpace(s)));
Contract.Requires(args.Length >= 2);
Contract.Requires(File.Exists(args[1]));
if (args.Length < 2)
{
Console.WriteLine("To start the PocketInvester Server use:");
Console.WriteLine("./Server.exe <predictor name> <path to FIXML>");
return;
}
Log.Write("PocketInvestor starting.");
ServerClass server = new ServerClass(args[0], args[1]);
if (args.Any(a => a.Equals("-genkeys")))
server.GenerateKeyFiles();
server.requestManager.StartServer();
}
示例7: Keywords
//.........这里部分代码省略.........
.Where
(
row => searchTerms.Any
(
term => row.title.ToLower().Contains(term)
)
);
var p2 = _productlist
.Where
(
row => searchTerms.Any
(
term => row.description.ToLower().Contains(term)
)
);
var p3 = _productlist
.Where
(
row => searchTerms.Any
(
term => row.keywords.ToLower().Contains(term)
)
);
_productlist = p1.Union(p2).ToList();
}
else if (mode == "all")
{
var p1 = _productlist
.Where
(
row => searchTerms.All
(
term => row.title.ToLower().Contains(term)
)
);
var p2 = _productlist
.Where
(
row => searchTerms.All
(
term => row.description.ToLower().Contains(term)
)
);
var p3 = _productlist
.Where
(
row => searchTerms.All
(
term => row.keywords.ToLower().Contains(term)
)
);
_productlist = p1.Union(p2).ToList();
//_productlist.Union(p3);
}
}
else if (fieldname == "title")
{
if (mode == "exact")
{
_productlist = _productlist
示例8: IsNumbers
public static Boolean IsNumbers(String value)
{
return value.All(Char.IsDigit);
}
示例9: comprobarTipos
public bool comprobarTipos(String telefono, String documento)
{
return (telefono.All(char.IsDigit) && documento.All(char.IsDigit));
}
示例10: comprobarTipos
public bool comprobarTipos(String precio, String cantidad)
{
return (precio.All(char.IsDigit) && cantidad.All(char.IsDigit));
}
示例11: CheckDigits
/// <summary>
/// Chequea que el string solo contenga digitos;
/// </summary>
/// <param name="value">String a chequear</param>
/// <exception cref="ExcepcionesSKD.InformacionPersonalInvalidaException">
/// Si el el valor contiene algún caracter que no sea dígito.
/// </exception>
private void CheckDigits(String value)
{
if (!value.All(char.IsDigit))
throw new InformacionPersonalInvalidaException("La información de Telefono solo deben ser digitos.");
}
示例12: isValidUsername
/*
* Validates that username is correct format
* Conditions:
* Special characters not allowed
* Spaces not allowed
* Between 4-12 characters in length
*/
public static bool isValidUsername(String username)
{
// Check for null
if (username == null)
{
return false;
}
// Minimum and Maximum Length of field - 4 to 12 Characters
if (username.Length < usernameLowerBoundary || username.Length > usernameUpperBoundary)
return false;
// Special Characters - Not Allowed
// Spaces - Not Allowed
if (!(username.All(c => char.IsLetterOrDigit(c))))
return false;
return true;
}
示例13: ValidateIntSearchKey
public bool ValidateIntSearchKey(String SearchKey)
{
Int64 id;
if (string.IsNullOrEmpty(SearchKey) || !SearchKey.All(i => Char.IsDigit(i)) || !Int64.TryParse(SearchKey, out id))
{
MessageBox.Show("Please enter valid search key");
return false;
}
return true;
}
示例14: ValidateNumber
public bool ValidateNumber(String Num)
{
// Home number validation
if (string.IsNullOrEmpty(Num) || !Num.All(C => Char.IsDigit(C)))
{
return false;
}
return true;
}
示例15: ValidateName
public bool ValidateName(String Name)
{
// Name Validation
if (string.IsNullOrEmpty(Name) || !Name.All(C => Char.IsLetter(C) || Char.IsWhiteSpace(C)))
{
MessageBox.Show("Please enter valid Name");
return false;
}
return true;
}