Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- XmlCodeExporter.cs
- XPathNodeInfoAtom.cs
- OdbcHandle.cs
- PixelFormats.cs
- ipaddressinformationcollection.cs
- RotateTransform3D.cs
- CodeDelegateInvokeExpression.cs
- XsdDuration.cs
- ValidatingPropertiesEventArgs.cs
- coordinatorfactory.cs
- Invariant.cs
- LassoHelper.cs
- HttpCapabilitiesSectionHandler.cs
- HotCommands.cs
- ExceptionHelpers.cs
- ArgumentValidation.cs
- StorageBasedPackageProperties.cs
- TypeDelegator.cs
- ExternalCalls.cs
- OleDbWrapper.cs
- HttpCapabilitiesEvaluator.cs
- KeyEventArgs.cs
- MethodCallConverter.cs
- SqlDataAdapter.cs
- EntityModelBuildProvider.cs
- RawStylusActions.cs
- TreeIterator.cs
- MobileControlsSectionHandler.cs
- EntityTransaction.cs
- MutexSecurity.cs
- _NestedSingleAsyncResult.cs
- basevalidator.cs
- _DigestClient.cs
- PerformanceCounterPermissionAttribute.cs
- EditorBrowsableAttribute.cs
- TextEditorMouse.cs
- BaseDataListComponentEditor.cs
- ParserStreamGeometryContext.cs
- TemplateColumn.cs
- JsonClassDataContract.cs
- NotifyCollectionChangedEventArgs.cs
- SkinBuilder.cs
- BuilderPropertyEntry.cs
- NamespaceList.cs
- WebPartTracker.cs
- X509ClientCertificateCredentialsElement.cs
- CodeArrayCreateExpression.cs
- AutomationFocusChangedEventArgs.cs
- RtfToXamlReader.cs
- InstanceNormalEvent.cs
- ResourceDefaultValueAttribute.cs
- HebrewCalendar.cs
- XamlDesignerSerializationManager.cs
- RequestQueryParser.cs
- WebCategoryAttribute.cs
- XPathNavigator.cs
- SqlConnectionPoolGroupProviderInfo.cs
- StackOverflowException.cs
- ApplicationFileCodeDomTreeGenerator.cs
- StrongName.cs
- DispatcherHooks.cs
- ActiveDesignSurfaceEvent.cs
- ProjectionNode.cs
- StackSpiller.Temps.cs
- Vector3DCollectionConverter.cs
- MetricEntry.cs
- PKCS1MaskGenerationMethod.cs
- AllowedAudienceUriElement.cs
- SolidColorBrush.cs
- EventManager.cs
- SchemaNamespaceManager.cs
- InternalBase.cs
- QueryCoreOp.cs
- ScalarConstant.cs
- XmlSchemaSimpleTypeList.cs
- SessionEndingEventArgs.cs
- MetadataExchangeBindings.cs
- MeshGeometry3D.cs
- EntityDataSourceChangedEventArgs.cs
- LoopExpression.cs
- ObjectHandle.cs
- TypeGeneratedEventArgs.cs
- ButtonBaseAutomationPeer.cs
- ParallelTimeline.cs
- LassoSelectionBehavior.cs
- Inline.cs
- PeerObject.cs
- ResourceDisplayNameAttribute.cs
- DataTransferEventArgs.cs
- ObjectViewListener.cs
- HtmlObjectListAdapter.cs
- RawStylusInputCustomDataList.cs
- MeasureData.cs
- RuntimeWrappedException.cs
- MouseButton.cs
- SafeNativeMethodsOther.cs
- ClientRolePrincipal.cs
- DataGridLength.cs
- WaitHandle.cs
- ServerProtocol.cs