DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Externalize Microservice Configuration With Spring Cloud Config
  • Selenium vs Cypress: Does Cypress Replace Selenium?
  • Handle HL7 MLLP Messages With Mule 4
  • Easy Oracle Database Migration with SQLcl

Trending

  • Java's Quiet Revolution: Thriving in the Serverless Kubernetes Era
  • Evolution of Cloud Services for MCP/A2A Protocols in AI Agents
  • Event-Driven Architectures: Designing Scalable and Resilient Cloud Solutions
  • Recurrent Workflows With Cloud Native Dapr Jobs
  1. DZone
  2. Coding
  3. JavaScript
  4. C# Interactive in Visual Studio

C# Interactive in Visual Studio

C# Interactive is an interesting REPL editor you can use in Visual Studio. Read on to learn how to set it up and use it for your project.

By 
Anoop Kumar Sharma user avatar
Anoop Kumar Sharma
DZone Core CORE ·
Sep. 14, 18 · Tutorial
Likes (6)
Comment
Save
Tweet
Share
81.7K Views

Join the DZone community and get the full member experience.

Join For Free

In this article, we will learn how to use C# Interactive in Visual Studio. The C# Interactive window has been a part of Visual Studio since the Visual Studio 2015 update 1 release. In this article, I am using Visual Studio 2017 for demonstration purposes. C# Interactive is a REPL Editor, i.e. Read-Evaluate-Print-Loop with an advanced editor. With the C# Interactive window, we can test our code snippet without compiling or running the complete code.

Let's Begin:

Open C# Interactive window in Visual Studio. We can open C# Interactive window in multiple ways:

  • From Menu Bar: Go to View Menu then move the cursor to Other Windows and then click on C# Interactive.

Image title

  • From context box: Right click on the .cs file and then click on Execute in Interactive (shortcut is Ctrl+E, Ctrl+E).

Image title


  • From Visual Studio command prompt: Open Visual Studio Developer command prompt.

Image title

Then type csi and press enter. C# Interactive mode will be available in the command prompt.

Image title

The C# Interactive window has 4 options in the window that is as below:

  1. Reset: Reset will reset all the DLLs, methods, etc., loaded in the C# Interactive window.

  2. Clear: Clear will clear the screen of the C# Interactive Window.

  3. History Previous: For checking the previous step/command executed in the C# Interactive Window.

  4. History Next: For checking the next step/command executed in the C# Interactive Window.

Image title

Execute Code in C# Interactive Window

We can execute C# code in the interactive window easily. In the below example, I have declared a string variable and displayed the output in the C# Interactive Window. C# Interactive window supports C# 6 and C# 7 as well.

Image title

Intelligence feature is also available in the Interactive window, which makes it easy to use.

Image title

We can execute any code block in the Interactive Window. For this, we have to just select the method which we want to test/access in the C# Interactive Window. Check the below example, I have created a Calculator class which has an Add, Subtract, Multiply, and Divide method.

Image title

Now select the method or function you want to test in the C# Interactive window and right-click and select Execute in Interactive.

Image title

Test the method by passing the parameter value in the method.

Image title

We can also load the DLL in REPL with the help of the #r command, followed by the path of the DLL to load in the C# Interactive Window.

Image title

C# Interactive Window also supports error handling in both compile time as well as runtime. Check the below screenshot:

Image title

Hope this will help you. Thanks!

Command (computing) Testing Clear (Unix) Reset (computing) History (command) Snippet (programming) Calculator (Mac OS) Strings Blocks

Published at DZone with permission of Anoop Kumar Sharma, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Externalize Microservice Configuration With Spring Cloud Config
  • Selenium vs Cypress: Does Cypress Replace Selenium?
  • Handle HL7 MLLP Messages With Mule 4
  • Easy Oracle Database Migration with SQLcl

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!