Schrodinger's cat new base class in ——. NET 4.1, open source Preview

Source: Internet
Author: User

From "Schrodinger's Cat",

The philosopher Schrödinger (Erwin Schrödinger) has an ideal experiment on quantum theory, as follows (for those who know quantum physics, please skip):

The cat was so pathetic that she (supposing it was a female cat to cause more compassion) was sealed in a Chamber of secrets with food-poisoned drugs. The poison bottle has a hammer, the hammer is controlled by an electronic switch, and the electronic switch is controlled by the radioactive atom. If the nucleus decays, it emits alpha particles, touches the electronic switch, drops the hammer, smashes the poison bottle, releases the cyanide gas inside it, and the female cat dies.

The Copenhagen faction says that before measuring, a particle's state is ambiguous and is in a mixed superposition of possibilities. such as a radioactive atom, when it decays is completely probabilistic. As long as there is no observation, it is in the decay/decay of the superposition state, only the actual measurement, it randomly selected a state to appear, so, because we do not observe, so the box of atoms in the decay/decay superposition state. Because the state of the atom is uncertain, the state of the cat is not certain, only when we open the box to see the final verdict: either the cat sprawling lying in the box, or it is alive and kicking "meow" straight. The question is, what state is the cat in before we open the box? It seems that the only possibility is that it is in superposition with our atoms, and the cat was caught in a dead/alive mixture.

Schrodinger's cat expresses an "uncertain state" in the real world, so can we also show an "indeterminate state" in OO programming?

That is to say: An object, when we do not use it, is a superposition of "string" and "cat", which, when used, can be either String or cat:

In programming, for a long time, type conversions are more rigorous: A String Object "hello123" cannot be directly expressed as an int value, because doing so often results in a exception of a type conversion.

Stringor<tother>

Ok, let's take a look at this generic class given by Daniel:

namespace System.QuantumEntanglement {
    public class StringOr<TOther> {
        public StringOr(string stringValue, TOther otherValue);

        public string StringValue { get; }
        public TOther OtherValue { get; }
    }
}

This Stringor class wraps a string together with a different type and has two get accessors, which return two types of values, and are very simple to use:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.