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
- IdnElement.cs
- ReturnValue.cs
- DataGridViewColumnCollection.cs
- RuleInfoComparer.cs
- DataRow.cs
- MultiView.cs
- Html32TextWriter.cs
- SafeProcessHandle.cs
- ReferencedType.cs
- RegionInfo.cs
- PerformanceCounterPermission.cs
- ParallelDesigner.xaml.cs
- BoolExpr.cs
- PathFigureCollection.cs
- ActivityXamlServices.cs
- CapabilitiesState.cs
- ArcSegment.cs
- XmlSchemaFacet.cs
- securitymgrsite.cs
- TimerTable.cs
- SelectedDatesCollection.cs
- CodeIdentifiers.cs
- FieldNameLookup.cs
- StrongNameKeyPair.cs
- SettingsPropertyIsReadOnlyException.cs
- TextComposition.cs
- ToolStripArrowRenderEventArgs.cs
- OrderedDictionaryStateHelper.cs
- UInt64Converter.cs
- ColorDialog.cs
- SqlDataSourceStatusEventArgs.cs
- XPathSelectionIterator.cs
- MultilineStringConverter.cs
- NetworkStream.cs
- DataColumnCollection.cs
- TableLayoutPanelBehavior.cs
- TextTrailingWordEllipsis.cs
- DataGridViewComboBoxCell.cs
- Parser.cs
- MediaTimeline.cs
- ToolStripDropTargetManager.cs
- XmlNamedNodeMap.cs
- PropertyEntry.cs
- VirtualPath.cs
- BaseValidator.cs
- NavigationWindow.cs
- HeaderUtility.cs
- Validator.cs
- RenderDataDrawingContext.cs
- FindProgressChangedEventArgs.cs
- TextWriterTraceListener.cs
- FormatException.cs
- CustomError.cs
- BamlLocalizableResourceKey.cs
- CodeMethodReturnStatement.cs
- SqlRecordBuffer.cs
- TextEditor.cs
- GridViewDeleteEventArgs.cs
- KeyValuePairs.cs
- StyleTypedPropertyAttribute.cs
- InvokeProviderWrapper.cs
- WebPartConnectionsCancelVerb.cs
- DateTimeParse.cs
- ToggleButtonAutomationPeer.cs
- SqlWorkflowPersistenceService.cs
- RectAnimationClockResource.cs
- CompositeScriptReference.cs
- TextSelectionHelper.cs
- ConstraintStruct.cs
- BufferedReadStream.cs
- Page.cs
- Binding.cs
- AutomationElementIdentifiers.cs
- UnsafeNativeMethods.cs
- XmlCollation.cs
- String.cs
- DynamicPhysicalDiscoSearcher.cs
- Collection.cs
- ClockController.cs
- HintTextConverter.cs
- ConfigurationManager.cs
- SizeLimitedCache.cs
- WorkflowApplicationCompletedEventArgs.cs
- VirtualizingStackPanel.cs
- ObjectDataSourceView.cs
- GraphicsContext.cs
- SettingsBindableAttribute.cs
- GAC.cs
- ChannelCredentials.cs
- TextServicesDisplayAttributePropertyRanges.cs
- RequestBringIntoViewEventArgs.cs
- SqlRetyper.cs
- DynamicMethod.cs
- ComboBoxAutomationPeer.cs
- SmiContext.cs
- UICuesEvent.cs
- WebPartConnectionsCancelVerb.cs
- DesignerObjectListAdapter.cs
- CounterSample.cs
- IdnMapping.cs