Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- OleDbStruct.cs
- EndCreateSecurityTokenRequest.cs
- DataBinder.cs
- Odbc32.cs
- DataFormats.cs
- DependsOnAttribute.cs
- MatrixAnimationUsingKeyFrames.cs
- PersonalizationProvider.cs
- AuthenticationException.cs
- WMIGenerator.cs
- DisplayMemberTemplateSelector.cs
- X509CertificateTokenFactoryCredential.cs
- MediaContextNotificationWindow.cs
- CompiledRegexRunnerFactory.cs
- HttpProfileBase.cs
- EnlistmentTraceIdentifier.cs
- Image.cs
- MergeFailedEvent.cs
- GenericArgumentsUpdater.cs
- DataGridViewUtilities.cs
- mediaeventshelper.cs
- UniqueEventHelper.cs
- XmlSchemas.cs
- BindingCollection.cs
- InfoCardRSAOAEPKeyExchangeDeformatter.cs
- KerberosSecurityTokenAuthenticator.cs
- DocumentXmlWriter.cs
- EncryptedType.cs
- Binding.cs
- MenuItemBindingCollection.cs
- HTTPNotFoundHandler.cs
- OutputCacheSettings.cs
- RequiredAttributeAttribute.cs
- Size.cs
- ApplicationException.cs
- XhtmlBasicValidationSummaryAdapter.cs
- KeyToListMap.cs
- DataColumnMappingCollection.cs
- BaseContextMenu.cs
- AsyncOperationManager.cs
- Attributes.cs
- Tag.cs
- TextEditorSpelling.cs
- DbModificationCommandTree.cs
- KeyEvent.cs
- PathSegmentCollection.cs
- DataContractSet.cs
- OperationCanceledException.cs
- RSAPKCS1SignatureFormatter.cs
- DependencyObjectCodeDomSerializer.cs
- WebPartCloseVerb.cs
- EditingCommands.cs
- MediaTimeline.cs
- TextBounds.cs
- ConfigurationStrings.cs
- Rotation3DAnimationBase.cs
- IIS7UserPrincipal.cs
- CheckBox.cs
- ConfigurationSectionGroupCollection.cs
- CounterSampleCalculator.cs
- _ScatterGatherBuffers.cs
- NativeBuffer.cs
- BaseDataList.cs
- SetIterators.cs
- StaticFileHandler.cs
- NameTable.cs
- SessionStateModule.cs
- SqlExpander.cs
- CryptoApi.cs
- DataContract.cs
- ColumnHeaderConverter.cs
- AsyncCompletedEventArgs.cs
- Rotation3D.cs
- sqlnorm.cs
- OdbcPermission.cs
- ZipIOCentralDirectoryFileHeader.cs
- LicenseException.cs
- SafeTimerHandle.cs
- CacheAxisQuery.cs
- OutputCacheSettingsSection.cs
- XmlKeywords.cs
- Control.cs
- BitmapInitialize.cs
- ConfigurationSectionCollection.cs
- CatalogPartChrome.cs
- NamedElement.cs
- CngAlgorithmGroup.cs
- FindResponse.cs
- remotingproxy.cs
- BitFlagsGenerator.cs
- ProfilePropertyMetadata.cs
- SqlRowUpdatedEvent.cs
- DocumentXPathNavigator.cs
- TextParentUndoUnit.cs
- DetailsViewUpdateEventArgs.cs
- FormClosedEvent.cs
- CuspData.cs
- ToolStripPanelSelectionGlyph.cs
- EntitySetDataBindingList.cs
- EnumerationRangeValidationUtil.cs