Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / DataWeb / Design / system / Data / Common / Utils / StringUtil.cs / 1 / StringUtil.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using System.Text; using System.Globalization; using System.Diagnostics; 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 [....] //--------------------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using System.Text; using System.Globalization; using System.Diagnostics; 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
- AssemblyFilter.cs
- DataBindingHandlerAttribute.cs
- DetailsViewAutoFormat.cs
- BooleanSwitch.cs
- GradientSpreadMethodValidation.cs
- SchemaMapping.cs
- FirewallWrapper.cs
- SQLMoneyStorage.cs
- OrderablePartitioner.cs
- WorkBatch.cs
- OleDbReferenceCollection.cs
- FileDialogCustomPlacesCollection.cs
- mactripleDES.cs
- DataServiceException.cs
- LeftCellWrapper.cs
- XNodeNavigator.cs
- TextViewSelectionProcessor.cs
- ManipulationStartedEventArgs.cs
- WS2007HttpBinding.cs
- DefaultBinder.cs
- MailAddress.cs
- RoutingUtilities.cs
- DefaultAssemblyResolver.cs
- IncomingWebResponseContext.cs
- ToolStripSystemRenderer.cs
- CaseCqlBlock.cs
- XmlSchemaImporter.cs
- StringWriter.cs
- VariableBinder.cs
- ClientSideQueueItem.cs
- Point3DKeyFrameCollection.cs
- OleDbWrapper.cs
- AdvancedBindingEditor.cs
- httpserverutility.cs
- ResourceDefaultValueAttribute.cs
- SubpageParagraph.cs
- HtmlTableRow.cs
- IdnMapping.cs
- SuppressIldasmAttribute.cs
- CompilationSection.cs
- ChangesetResponse.cs
- ExceptionAggregator.cs
- ZipIORawDataFileBlock.cs
- EllipseGeometry.cs
- LocalIdKeyIdentifierClause.cs
- TextTreeFixupNode.cs
- DESCryptoServiceProvider.cs
- CodeAttributeDeclarationCollection.cs
- DataGridViewCellStyleConverter.cs
- UpdatePanelTriggerCollection.cs
- DataTableExtensions.cs
- DelimitedListTraceListener.cs
- KeyboardEventArgs.cs
- FileAuthorizationModule.cs
- SingleStorage.cs
- DecodeHelper.cs
- SecurityState.cs
- SmiSettersStream.cs
- CommentEmitter.cs
- XamlToRtfParser.cs
- ImagingCache.cs
- MultiPageTextView.cs
- ProxyWebPart.cs
- DataGridViewToolTip.cs
- MetadataArtifactLoaderCompositeResource.cs
- ReachPageContentSerializerAsync.cs
- MissingSatelliteAssemblyException.cs
- FreezableOperations.cs
- CFGGrammar.cs
- RIPEMD160.cs
- RouteUrlExpressionBuilder.cs
- ScriptBehaviorDescriptor.cs
- GenerateScriptTypeAttribute.cs
- QueryAsyncResult.cs
- GenericTextProperties.cs
- ServerIdentity.cs
- SapiRecoContext.cs
- InputQueue.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- BinaryObjectReader.cs
- PageBreakRecord.cs
- Viewport3DAutomationPeer.cs
- FacetChecker.cs
- ExpressionBindings.cs
- ISAPIApplicationHost.cs
- KerberosSecurityTokenAuthenticator.cs
- Compiler.cs
- DbDataReader.cs
- DbFunctionCommandTree.cs
- BehaviorDragDropEventArgs.cs
- RoleManagerModule.cs
- DependencyObjectType.cs
- ActivityDefaults.cs
- MouseWheelEventArgs.cs
- OleStrCAMarshaler.cs
- DataGridViewCellCollection.cs
- XmlSchemaDocumentation.cs
- ParameterCollection.cs
- BinaryEditor.cs
- DrawingAttributesDefaultValueFactory.cs