VS 2015 Pretty good features: C # Interactive window

Source: Internet
Author: User

According to the Convention, Old week is the first to brag about the business. Blow this thing up for everyone today.

Some netizens do not know whether to drink high last night, incredibly study from the old week. To tell you the truth, the old week is not a good study, the old week is not a compiler, the old week is just a free from the great good big evil between the ordinary people, said is only:

To find sorrow for no reason, sometimes as silly as crazy. Even if the birth of a good vessel, the original Robin Hood in the abdomen. Do not pass the world affairs, foolish afraid to read the article. The behavior of the remote sex perverse, that the world slander!

Old weeks on the road, not the sage, under the matter of the villain, among insects, leisurely in the world of a tiny dust. So, don't study the old weeks.

Users interested in the old week how you learned to program, but also completely self-taught.

Alas, to talk about this, to tell you the truth, the old week desperately write code is no purpose, no fame, unconditional, is curious, and then is like. The hole Grandpa said really TMD good, "the person who knows is inferior to the good, the good person is inferior to the happy person", says also, you do not like the thing, best not to learn, finally is the study is not good. Therefore, if you choose to study, then accept win their hearts bar, for this, the old week no particularly good advice, or that sentence: Accept win their hearts bar.

==========================================================

Well, the gossip is over, and the following is a serious matter. VS 2015 has a feature that I quite like, which is a window called "C # interaction" Under the "View"-"Other Windows" menu, which is simply a window of great love.

Why? Before, if you want to write some small test code, you have to create a new project, and then write code to do the test. It's not good to build a project for a little bit of content. However, now that the VS 2015 has this interactive feature, it is much easier to test the code, and you can do so in this window:

1, direct input C # code;

2, there are smart tips;

3, real-time compilation, calculation of expression results.

Does it feel iffy? No, at least not the fantasy novel that the Bastard, but definitely a good function.

Fart words less say, come, the old week teaches you to play, very cool.

Open vs 2015, enter "C # interaction" In the Quick Launch input box in the upper-right corner, then find the command below the [view] menu and click directly.

Then you will see this window:

Similar to the Command Prompt window, if I now want to know what the maximum value of int type is, you enter directly:

Int. MaxValue

Then press ENTER and you will see the results of the live execution.

For example, the environment class has a static property processorcount that can get the number of CPUs on the computer, including the number of cores and threads. Input:

Environment.processorcount

Then press ENTER to see

Dual core four thread, return 4.

-----------------------------------------------------------------------

No, let's go ahead. When using cryptographic APIs, especially bidirectional encryption, you usually want to know the number of bits of key and IV. For example, the AES algorithm, I would like to know its key and IV are the number of bits respectively. Come on, do it.

First, the namespace is introduced, and every sentence you lose is a return.

using System.Security.Cryptography;

New A Aescryptoserviceprovider instance:

Aescryptoserviceprovider PRD = new Aescryptoserviceprovider ();

Enter the following expression to get the number of bits in the key.

Prd. KeySize

Finally, look at the overall effect.

How, stimulate not.

------------------------------------------------------------------------------------------------------

For example, if I want to create an XML document using the XDocument class below System.Xml.Linq, this window will only refer to the system by default, Mscorelib and System.core, and there is no reference to the SYSTEM.XML.LINQ assembly, how do you do it?

Don't be afraid, this window also supports dynamic referencing of assemblies, entering:

#r "System.Xml.Linq"

Begins with #r, then a space, followed by a character expression, which is the name of the assembly. Also, you have smart hints when you type.

Then you can have the using.

Using System.Xml.Linq;

Let's build an XML document below.

XDocument doc = new XDocument (New XElement ("root", New XElement ("book", "South Travels"));

After the carriage return, the code executes.

Then look at what's in the new XML document. Directly enter the variable name doc, and then enter, automatically calling its ToString method.

Doc

Finally, the results are as follows.

If you want to clear the contents of a window, enter it directly:

#cls

then enter.

This interactive window is powerful enough.

OK, today's show is over, thanks for watching.

VS 2015 Pretty good features: C # Interactive window

Related Article

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.