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 8049921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:55:22+00:00 2026-06-05T06:55:22+00:00

I know that it’s impossible to cast string or bool like (int)MyString (short)MyBool and

  • 0

I know that it’s impossible to cast string or bool like (int)MyString (short)MyBool and so on while it’s allowed to cast int to short.

Unfortunately I could not find explanation, why. So I’m asking it here.

Why is not allowed explicitly cast some data types (I am not asking how to convert string to other types or something like this)?

  • 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-05T06:55:23+00:00Added an answer on June 5, 2026 at 6:55 am

    Refer: Casting and Type Conversions (C# Programming Guide)

    Explicit conversions (casts): Explicit conversions require a cast
    operator. Casting is required when information might be lost in the
    conversion, or when the conversion might not succeed for other
    reasons. Typical examples include numeric conversion to a type that
    has less precision or a smaller range, and conversion of a base-class
    instance to a derived class.

    From: Explicit Conversion

    Explicit conversion is required by some compilers to support narrowing
    conversions. It is a language-specific way to perform conversion. In
    some languages, like C# and C++, explicit conversion is performed
    using casting. Casting occurs when you prefix a conversion with a data
    type that defines the type of the conversion you want to perform. In
    Visual Basic, the CType function is used to allow explicit conversions
    of data types that are not allowed implicitly.

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

Sidebar

Related Questions

I know that I can do something like $int = (int)99; //(int) has a
I know that I can use something like string[3:4] to get a substring in
I know that some of the Microsoft employees are members of StackOverflow like the
i know that if can be writen in short way syntax in c please
I know that this question might have been asked like 100 times, but, believe
I know that objects are treated pretty much like singletons in scala. However, I
I know that the following is true int i = 17; //binary 10001 int
I know that there is a way to make a for loop work like
I know that it is possible to create layer masks in C4 like this:
I know that it's a subject that can raise a lot of debate, but

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.