Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9016623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:02:38+00:00 2026-06-16T04:02:38+00:00

http://msdn.microsoft.com/en-us/library/1x308yk8.aspx This allows me to do this: var str = string ; Char.IsWhiteSpace(str, 6);

  • 0

http://msdn.microsoft.com/en-us/library/1x308yk8.aspx

This allows me to do this:

var str = "string ";
Char.IsWhiteSpace(str, 6);

Rather than:

Char.IsWhiteSpace(str[6]);

Seems unusual, so I looked at the reflection:

[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public static bool IsWhiteSpace(char c)
{
    if (char.IsLatin1(c))
    {
        return char.IsWhiteSpaceLatin1(c);
    }
    return CharUnicodeInfo.IsWhiteSpace(c);
}

[SecuritySafeCritical]
public static bool IsWhiteSpace(string s, int index)
{
    if (s == null)
    {
        throw new ArgumentNullException("s");
    }
    if (index >= s.Length)
    {
        throw new ArgumentOutOfRangeException("index");
    }
    if (char.IsLatin1(s[index]))
    {
        return char.IsWhiteSpaceLatin1(s[index]);
    }
    return CharUnicodeInfo.IsWhiteSpace(s, index);
}

Three things struck me:

  1. Why does it bother to do the limit check only on the upper bound? Throwing an ArgumentOutOfRangeException, while index below 0 would give string’s standard IndexOutOfRangeException
  2. The precense of SecuritySafeCriticalAttribute which I’ve read the general blerb about, but still unclear what it is doing here and if it is linked to the upper bound check.
  3. TargetedPatchingOptOutAttribute is not present on other Is...(char) methods. Example IsLetter, IsNumber etc.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T04:02:41+00:00Added an answer on June 16, 2026 at 4:02 am

    Because not every character fits in a C# char. For instance, "" takes 2 C# chars, and you couldn’t get any information about that character with just a char overload. With String and an index, the methods can see if the character at index i is a High Surrogate char, and then read the Low Surrogate char at next index, add them up according to the algorithm, and retrieve info about the code point U+20000.

    This is how UTF-16 can encode 1 million different code points, it’s a variable-width encoding. It takes 2-4 bytes to encode a character, or 1-2 C# chars.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

http://msdn.microsoft.com/en-us/library/ms189797.aspx In this link they are committing a transaction within catch clause IF (XACT_STATE())
http://msdn.microsoft.com/en-us/library/system.resources.resxresourcewriter.aspx In this link and others like it, I see code to write in
Re: http://msdn.microsoft.com/en-us/library/system.io.file.exists.aspx Does anyone know if this is a particularly slow or locking operation
This link http://msdn.microsoft.com/en-us/library/aa772153(VS.85).aspx says: You can register up to five notification requests on a
http://msdn.microsoft.com/en-us/library/435f1dw2.aspx public class Base { public string Field; } public class Child : Base
http://msdn.microsoft.com/en-us/library/dd371799(v=VS.85).aspx So with a signature like this: BOOL WINAPI AssociateColorProfileWithDevice( PCTSTR pMachineName, PCTSTR pProfileName,
link http://msdn.microsoft.com/en-us/library/ee796239%28v=vs.91%29.aspx#Y3078 the code return this.ObjectContext.SalesOrderHeaders.OrderBy(e=>e.SalesOrderID); note have done and checked everything done till
From http://msdn.microsoft.com/en-us/library/aa287786(v=vs.71).aspx public string Name { get { return name; } set { name
The MSDN documentation: http://msdn.microsoft.com/en-us/library/ms724897(VS.85).aspx Is strangely silent on what errors this function might return.
This article here http://msdn.microsoft.com/en-us/library/bb188204%28v=sql.90%29.aspx?ppud=4 describes how to log SQL requests sent via ODBC. Does

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.