Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 27
    I do not understand what this answer means and why it was upvoted. You can use typeof(string) in reflection. Example one: if (someMethodInfo.ReturnType == typeof(string)) { ... } Example two: var p = typeof(string).GetProperty("FirstChar", BindingFlags.NonPublic | BindingFlags.Instance); Where is it that you must use String, not string? If you try things like Type.GetType("String") or Type.GetType("string"), neither will find the class because the namespace is missing. If for some silly reason you compare .Name of a type to "string" in a case-sensitive way, you are right. Commented May 24, 2019 at 12:04
  • Please explain. Commented Jul 21, 2022 at 7:40
  • I don't think this is true. The compiler changes string into global::System.String so there's no reason string couldn't be used in reflection. Commented May 15, 2023 at 13:02
  • Lemmings, upvoting just because someone else upvoted. Commented Jun 21, 2024 at 13:21