About 24,400,000 results
Open links in new tab
  1. Type-testing operators and cast expressions

    C# language specification. For more information, see the following sections of the C# language specification: The is operator; The as operator; Cast expressions; The typeof operator; See also. C# operators and expressions; How to safely cast by using pattern matching and the is and as operators; Generics in .NET

  2. What's the point of "As" keyword in C# - Stack Overflow

    Oct 23, 2015 · Does 'as' keyword in C# only converts Object type variables to the type I desire?

  3. C# | as Operator Keyword - GeeksforGeeks

    Aug 23, 2022 · So, to overcome such types of exception C# provides the operator keyword as. The as operator is used to perform conversion between compatible reference types or Nullable types. This operator returns the object when they are compatible with the given type and return null if the conversion is not possible instead of raising an exception.

  4. c# - Direct casting vs 'as' operator? - Stack Overflow

    Sep 25, 2008 · you can definitely do that but it's not exactly best practice because you don't want to rely on the caller or external systems to ensure your value isn't null. If you're using C#6 then you could do (o as string)?. ToLower(). –

  5. How to safely cast by using pattern matching and the is and as ...

    Mar 11, 2022 · C# provides pattern matching statements that perform a cast conditionally only when it will succeed. C# also provides the is and as operators to test if a value is of a certain type. The following example shows how to use the pattern matching is statement: var g = new Giraffe(); var a = new Animal(); FeedMammals(g); FeedMammals(a); // Output ...

  6. casting - C# "as" cast vs classic cast - Stack Overflow

    Specifically the as operator only allows for the following (from section 7.9.11 of the C# lang spec) An identity (§6.1.1), implicit reference (§6.1.6), boxing (§6.1.7), explicit reference (§6.2.4), or unboxing (§6.2.5) conversion exists from the type of E to T.

  7. The Is and As Operators in C# - C# Corner

    May 31, 2024 · In C#, the "is" operator checks if an object is of a specified type, returning a boolean. The "as" operator attempts to cast an object to a specified type, returning null if the cast fails.

  8. How to use the is and as operators in C# - InfoWorld

    Jul 13, 2023 · The as operator in C# allows you to explicitly convert the result of an expression to a given reference type or a nullable value type. If the conversion isn’t possible, as returns null.

  9. 'is' And 'as' Keywords In C# - C# Corner

    In this blog, I am going to share with you about 'as' and 'is' keywords in C#. Introduction 'as' and 'is' are the keywords used for conversion/TypeCasting in C#.

  10. It Is What It Is and As It Is: Using the Is and As Operators in C#

    Jan 9, 2020 · This guide will clarify the difference between the "Is" and "As" Operators in C# and help you incorporate them into your applications effectively.

  11. Some results have been removed
Refresh