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
- NavigationWindowAutomationPeer.cs
- Win32Native.cs
- InfiniteTimeSpanConverter.cs
- RangeContentEnumerator.cs
- FileSystemInfo.cs
- VirtualPath.cs
- OdbcConnectionFactory.cs
- Expressions.cs
- TimelineGroup.cs
- RotateTransform3D.cs
- Queue.cs
- DbConnectionHelper.cs
- HandlerMappingMemo.cs
- CodeAccessPermission.cs
- ComNativeDescriptor.cs
- ComAwareEventInfo.cs
- TransportOutputChannel.cs
- SignedPkcs7.cs
- DeploymentSection.cs
- GlyphManager.cs
- ImageDrawing.cs
- LockedHandleGlyph.cs
- SqlConnectionHelper.cs
- PersistenceException.cs
- SafeCoTaskMem.cs
- Style.cs
- HttpResponseHeader.cs
- SafeLocalMemHandle.cs
- storepermissionattribute.cs
- PartialTrustVisibleAssembliesSection.cs
- AttributeData.cs
- EntityConnectionStringBuilderItem.cs
- ReliableSessionBindingElementImporter.cs
- BrowserTree.cs
- XmlSchemaAnnotation.cs
- TargetParameterCountException.cs
- ListSortDescription.cs
- Logging.cs
- InfoCardService.cs
- StrokeNode.cs
- ExtensionFile.cs
- AppDomainAttributes.cs
- DbConnectionPoolOptions.cs
- Bold.cs
- ReversePositionQuery.cs
- InsufficientMemoryException.cs
- Error.cs
- NTAccount.cs
- DataGridViewCheckBoxCell.cs
- EncryptedPackageFilter.cs
- odbcmetadatafactory.cs
- CodeConditionStatement.cs
- TempEnvironment.cs
- Rect3DValueSerializer.cs
- EventProviderTraceListener.cs
- XmlCharacterData.cs
- TypeDelegator.cs
- SrgsToken.cs
- ModelProperty.cs
- MultipartContentParser.cs
- UshortList2.cs
- Base64Encoding.cs
- Rule.cs
- AppDomainProtocolHandler.cs
- Utilities.cs
- AppSettingsReader.cs
- ISO2022Encoding.cs
- XPathConvert.cs
- QueryCacheKey.cs
- DataControlPagerLinkButton.cs
- KeyProperty.cs
- Color.cs
- SoapMessage.cs
- QuotedPrintableStream.cs
- XPathDocumentBuilder.cs
- ToolStripButton.cs
- CodeDirectiveCollection.cs
- ResolveNameEventArgs.cs
- CookieHandler.cs
- CardSpacePolicyElement.cs
- TextOutput.cs
- Overlapped.cs
- BitSet.cs
- ConnectionManager.cs
- RuntimeArgumentHandle.cs
- MultiPropertyDescriptorGridEntry.cs
- SoapObjectWriter.cs
- UnmanagedBitmapWrapper.cs
- ObjectDataSourceView.cs
- WebHttpDispatchOperationSelector.cs
- BaseHashHelper.cs
- ConfigXmlSignificantWhitespace.cs
- RectValueSerializer.cs
- InvalidFilterCriteriaException.cs
- RealizedColumnsBlock.cs
- CharEntityEncoderFallback.cs
- XomlCompilerError.cs
- Int32.cs
- DataServiceQuery.cs
- RectangleGeometry.cs