Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataWeb / Design / system / Data / Common / Utils / StringUtil.cs / 1305376 / StringUtil.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- namespace System.Data.Common.Utils { // This class provides some useful string utilities, e.g., converting a // list to string. internal static class StringUtil { ////// This private static method checks a string to make sure that it is not empty. /// Comparing with String.Empty is not sufficient since a string with nothing /// but white space isn't considered "empty" by that rationale. /// internal static bool IsNullOrEmptyOrWhiteSpace(string value) { return IsNullOrEmptyOrWhiteSpace(value, 0); } internal static bool IsNullOrEmptyOrWhiteSpace(string value, int offset) { // don't use Trim(), which will copy the string, which may be large, just to test for emptyness //return String.IsNullOrEmpty(value) || String.IsNullOrEmpty(value.Trim()); if (null != value) { for(int i = offset; i < value.Length; ++i) { if (!Char.IsWhiteSpace(value[i])) { return false; } } } return true; } // separate implementation from IsNullOrEmptyOrWhiteSpace(string, int) because that one will // pick up the jit optimization to avoid boundary checks and the this won't is unknown (most likely not) internal static bool IsNullOrEmptyOrWhiteSpace(string value, int offset, int length) { // don't use Trim(), which will copy the string, which may be large, just to test for emptyness //return String.IsNullOrEmpty(value) || String.IsNullOrEmpty(value.Trim()); if (null != value) { length = Math.Min(value.Length, length); for(int i = offset; i < length; ++i) { if (!Char.IsWhiteSpace(value[i])) { return false; } } } return true; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- namespace System.Data.Common.Utils { // This class provides some useful string utilities, e.g., converting a // list to string. internal static class StringUtil { ////// This private static method checks a string to make sure that it is not empty. /// Comparing with String.Empty is not sufficient since a string with nothing /// but white space isn't considered "empty" by that rationale. /// internal static bool IsNullOrEmptyOrWhiteSpace(string value) { return IsNullOrEmptyOrWhiteSpace(value, 0); } internal static bool IsNullOrEmptyOrWhiteSpace(string value, int offset) { // don't use Trim(), which will copy the string, which may be large, just to test for emptyness //return String.IsNullOrEmpty(value) || String.IsNullOrEmpty(value.Trim()); if (null != value) { for(int i = offset; i < value.Length; ++i) { if (!Char.IsWhiteSpace(value[i])) { return false; } } } return true; } // separate implementation from IsNullOrEmptyOrWhiteSpace(string, int) because that one will // pick up the jit optimization to avoid boundary checks and the this won't is unknown (most likely not) internal static bool IsNullOrEmptyOrWhiteSpace(string value, int offset, int length) { // don't use Trim(), which will copy the string, which may be large, just to test for emptyness //return String.IsNullOrEmpty(value) || String.IsNullOrEmpty(value.Trim()); if (null != value) { length = Math.Min(value.Length, length); for(int i = offset; i < length; ++i) { if (!Char.IsWhiteSpace(value[i])) { return false; } } } return true; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ObfuscationAttribute.cs
- BasicCommandTreeVisitor.cs
- CompensateDesigner.cs
- XmlQueryType.cs
- HashHelper.cs
- InheritablePropertyChangeInfo.cs
- MasterPageParser.cs
- Rule.cs
- PlatformNotSupportedException.cs
- RenderOptions.cs
- DataGridViewSelectedCellCollection.cs
- XNodeValidator.cs
- Stylus.cs
- PointAnimationUsingPath.cs
- Certificate.cs
- InternalSafeNativeMethods.cs
- DbConnectionPoolIdentity.cs
- DetailsViewUpdatedEventArgs.cs
- XmlUtil.cs
- XamlTreeBuilder.cs
- JournalEntry.cs
- TypeSource.cs
- ButtonChrome.cs
- SmiEventSink.cs
- CutCopyPasteHelper.cs
- GroupLabel.cs
- DataGridToolTip.cs
- X509IssuerSerialKeyIdentifierClause.cs
- DES.cs
- JsonClassDataContract.cs
- RelationshipEnd.cs
- _SslSessionsCache.cs
- SubpageParagraph.cs
- ConfigPathUtility.cs
- RecordBuilder.cs
- StubHelpers.cs
- SurrogateSelector.cs
- DataContractSerializerSection.cs
- XmlILStorageConverter.cs
- PseudoWebRequest.cs
- SqlUDTStorage.cs
- DoubleKeyFrameCollection.cs
- DynamicDiscoSearcher.cs
- RightsManagementEncryptedStream.cs
- PKCS1MaskGenerationMethod.cs
- LicFileLicenseProvider.cs
- UIElementCollection.cs
- ListParaClient.cs
- ReachSerializer.cs
- FileDialog.cs
- BlurBitmapEffect.cs
- HtmlTableCell.cs
- LazyLoadBehavior.cs
- TdsParser.cs
- BinaryFormatter.cs
- SubMenuStyle.cs
- WindowsFont.cs
- WebPartMenuStyle.cs
- ScriptBehaviorDescriptor.cs
- MailAddressCollection.cs
- FixedSOMSemanticBox.cs
- MailHeaderInfo.cs
- ToolboxItemImageConverter.cs
- TdsParser.cs
- WizardDesigner.cs
- XmlLanguage.cs
- EnvironmentPermission.cs
- WriteStateInfoBase.cs
- FixedDocument.cs
- PropertyChangedEventArgs.cs
- NamespaceEmitter.cs
- SystemEvents.cs
- ListViewCancelEventArgs.cs
- FormsIdentity.cs
- MouseActionValueSerializer.cs
- AnnotationComponentManager.cs
- DataObjectMethodAttribute.cs
- DiffuseMaterial.cs
- DataSourceControl.cs
- Ipv6Element.cs
- SpecialFolderEnumConverter.cs
- StructuralObject.cs
- unsafeIndexingFilterStream.cs
- SignatureToken.cs
- DetailsViewRow.cs
- XmlSchemaObjectCollection.cs
- VirtualDirectoryMappingCollection.cs
- PropertyChangedEventManager.cs
- CommandPlan.cs
- HttpCookiesSection.cs
- LogicalExpressionTypeConverter.cs
- TreeViewDesigner.cs
- FixedFindEngine.cs
- PhotoPrintingIntent.cs
- _FixedSizeReader.cs
- MailAddressCollection.cs
- MessageBox.cs
- Int16Storage.cs
- ClientTargetSection.cs
- CodeVariableReferenceExpression.cs