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


C# Validator.GetPhoneNumber方法代码示例

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


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

示例1: Main


//.........这里部分代码省略.........
            Console.Write( validator.GetNullableSqlSmallDateTimeExact( vp, "fred", "MM/dd/yyy", false ) );
            Assert.IsFalse( vp.LastResult == ErrorCondition.NoError );

            vp = new ValidationErrorHandler( errorWriter );
            Console.WriteLine( validator.GetInt( vp, "fred" ) );
            Assert.IsFalse( vp.LastResult == ErrorCondition.NoError );

            vp = new ValidationErrorHandler( errorWriter ); // "myGoodInt" );
            Console.WriteLine( validator.GetInt( vp, "-342" ) );
            Assert.IsFalse( vp.LastResult != ErrorCondition.NoError );

            vp = new ValidationErrorHandler( errorWriter ); // "myBadDate" );
            Console.WriteLine( validator.GetSqlSmallDateTimeFromParts( vp, "3", "", "" ) );
            Assert.IsFalse( vp.LastResult == ErrorCondition.NoError );

            vp = new ValidationErrorHandler( errorWriter ); // "myBadDate" );
            Console.WriteLine( validator.GetSqlSmallDateTimeFromParts( vp, "", "", "" ) );
            Assert.IsFalse( vp.LastResult == ErrorCondition.NoError );

            vp = new ValidationErrorHandler( errorWriter ); // "zip" );
            Console.WriteLine( validator.GetZipCode( vp, "14580", true ).FullZipCode );
            Assert.IsFalse( vp.LastResult != ErrorCondition.NoError );

            vp = new ValidationErrorHandler( errorWriter ); // "zip" );
            Console.WriteLine( validator.GetZipCode( vp, "14580-1234", true ).FullZipCode );
            Assert.IsFalse( vp.LastResult != ErrorCondition.NoError );

            vp = new ValidationErrorHandler( errorWriter ); // "badZip" );
            Console.WriteLine( validator.GetZipCode( vp, "123", false ).FullZipCode );
            Assert.IsFalse( vp.LastResult == ErrorCondition.NoError );

            Console.WriteLine( "---------------------------------\nPhone Numbers:\n------------------------------------\n" );
            vp = new ValidationErrorHandler( errorWriter );
            Console.WriteLine( validator.GetPhoneNumber( vp, "5854556476", true, true, false ) );
            Assert.IsFalse( vp.LastResult != ErrorCondition.NoError );

            vp = new ValidationErrorHandler( errorWriter );
            Console.WriteLine( validator.GetPhoneNumber( vp, "585 4556476", true, true, false ) );
            Assert.IsFalse( vp.LastResult != ErrorCondition.NoError );

            vp = new ValidationErrorHandler( errorWriter );
            Console.WriteLine( validator.GetPhoneNumber( vp, "( 585 )455-6476", true, true, false ) );
            Assert.IsFalse( vp.LastResult != ErrorCondition.NoError );

            vp = new ValidationErrorHandler( errorWriter );
            Console.WriteLine( validator.GetPhoneNumber( vp, "(585)455-6476", true, true, false ) );
            Assert.IsFalse( vp.LastResult != ErrorCondition.NoError );

            vp = new ValidationErrorHandler( errorWriter );
            Console.WriteLine( validator.GetPhoneNumber( vp, "585-455-6476", true, true, false ) );
            Assert.IsFalse( vp.LastResult != ErrorCondition.NoError );

            vp = new ValidationErrorHandler( errorWriter );
            Console.WriteLine( "With lots of spaces: " + validator.GetPhoneNumber( vp, "585   872   0291  ", true, true, false ) );
            Assert.IsFalse( vp.LastResult != ErrorCondition.NoError );

            vp = new ValidationErrorHandler( errorWriter );
            Console.WriteLine( "With x: " + validator.GetPhoneNumber( vp, "5854556476   x   12345", true, true, false ) );
            Assert.IsFalse( vp.LastResult != ErrorCondition.NoError );

            vp = new ValidationErrorHandler( errorWriter );
            Console.WriteLine( "With space ext. allowed: " + validator.GetPhoneNumber( vp, "5854556476 12345", true, true, false ) );
            Assert.IsFalse( vp.LastResult != ErrorCondition.NoError );

            vp = new ValidationErrorHandler( errorWriter );
            Console.WriteLine( "Toni example 1: " + validator.GetPhoneNumber( vp, "321-663-4810", true, true, false ) );
开发者ID:william-gross,项目名称:enterprise-web-library,代码行数:67,代码来源:RsLibraryTester.cs


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