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
- __Filters.cs
- LayoutSettings.cs
- XmlTextAttribute.cs
- ConfigUtil.cs
- ChtmlMobileTextWriter.cs
- X509Certificate2Collection.cs
- DataTemplate.cs
- DbCommandTree.cs
- ProfileProvider.cs
- Opcode.cs
- OrCondition.cs
- ResourceReferenceExpressionConverter.cs
- DmlSqlGenerator.cs
- NotImplementedException.cs
- WebConfigurationManager.cs
- ClientProxyGenerator.cs
- Int64KeyFrameCollection.cs
- ProfileSection.cs
- SQLDecimalStorage.cs
- UIElement3DAutomationPeer.cs
- EnumValAlphaComparer.cs
- Queue.cs
- DockAndAnchorLayout.cs
- FusionWrap.cs
- ResXBuildProvider.cs
- ExpandSegment.cs
- PrinterResolution.cs
- ScalarOps.cs
- ReadOnlyObservableCollection.cs
- SystemResources.cs
- FieldBuilder.cs
- EventProviderWriter.cs
- XNameConverter.cs
- RSAPKCS1SignatureFormatter.cs
- BStrWrapper.cs
- DataControlButton.cs
- CFStream.cs
- LoadMessageLogger.cs
- AssemblyHash.cs
- PasswordRecovery.cs
- CodeStatementCollection.cs
- MouseActionConverter.cs
- SimpleModelProvider.cs
- DataDocumentXPathNavigator.cs
- NullableFloatMinMaxAggregationOperator.cs
- AxDesigner.cs
- SchemaComplexType.cs
- DataService.cs
- SemanticTag.cs
- Binding.cs
- HotSpot.cs
- DataSetFieldSchema.cs
- DataPagerFieldCollection.cs
- OdbcCommand.cs
- PaintEvent.cs
- Trace.cs
- Menu.cs
- StrongName.cs
- CorrelationManager.cs
- CharStorage.cs
- InputDevice.cs
- UIElement.cs
- ImageAttributes.cs
- DBBindings.cs
- JsonFormatGeneratorStatics.cs
- OrderedDictionaryStateHelper.cs
- RelationshipEndMember.cs
- ReflectionServiceProvider.cs
- RadioButton.cs
- Button.cs
- Line.cs
- HierarchicalDataTemplate.cs
- IDQuery.cs
- Publisher.cs
- ListViewInsertionMark.cs
- Style.cs
- UnsafeNativeMethods.cs
- DataBoundControlAdapter.cs
- CrossAppDomainChannel.cs
- NameSpaceEvent.cs
- WindowsPen.cs
- TextTrailingWordEllipsis.cs
- IDataContractSurrogate.cs
- ConfigurationValues.cs
- XPathEmptyIterator.cs
- WebPartMenuStyle.cs
- DataGridViewComboBoxColumnDesigner.cs
- GroupByExpressionRewriter.cs
- TargetControlTypeAttribute.cs
- Block.cs
- ProcessInfo.cs
- objectresult_tresulttype.cs
- MessageContractExporter.cs
- CrossSiteScriptingValidation.cs
- KeyGestureConverter.cs
- StatusBar.cs
- HuffCodec.cs
- XappLauncher.cs
- SqlXml.cs
- DbQueryCommandTree.cs