• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • Home
  • Featured
    • C# Tutorials
      • LinQ Tutorials
      • Facebook C# API Tutorials
    • PHP Tutorials
      • CodeIgniter Tutorials
    • Amazon AWS Tutorials
  • Categories
    • Programming
    • Development
    • Database
    • Web Server
    • Source Control
    • Management
    • Project
  • About
  • Write
  • Contact

CodeSamplez.com

Programming, Web development, Cloud Technologies

You are here: Home / Development / Vistual Studio .NET Tips And Tricks

Vistual Studio .NET Tips And Tricks

July 13, 2012 by Rana Ahsan Leave a Comment

Visual Studio .NET

Sometimes, while working, we face some silly problems which are very easy to solve by nature, but we can’t figure that out at that moment and waste some valuable time finding their solutions. Similar happens to some other scenario, where we knew what to do to get a certain result, but can’t memorize particularly. I was thinking to make a list of these small things in my blog, which will might be helpful for myself and may be to other audiences(I hope :)). I am planning to create different article for different type of development environment. Today, I will explain about some such very quick/small .NET tips and tricks, for visual studio environment. I usually use visual studio 2010.

Show Line Numbers On VS Editor:

I still remember, when, at the very beginning of my familiarity with visual studio, I was often forgot how to show the line number on my code editor. By default, it isn’t enabled by visual studio. But its somehow very important to remember it in a long file of code. What you will have to do, is to go to “Tools->Options->Text Editor->All Language->General” and check the box titled ‘Line numbers’ under ‘Display’ section. See the image below for more accurate idea:
Show Line Number On Visual Studio

If you need to do this for a specific programming language, you can do so as well. Just find this similar settings under that specific programming language(like c#), instead of ‘general’.

Using ‘Region’ And ‘If’ Directives:

Did you know, we can use these directive in various useful scenario to keep our code manageable and easy to debug. These can be used in any programming language that .NET supports. There are few more directives though, these two seems very useful to me. These directives are used anywhere in the code file and starts/ends with ‘#’ character. Please check here to see details about more directives.

Using the region block, you can combine the related properties/methods/code block in a single collapsible/expandable section. In this way, if you use it through the file, even a long coded file also becomes easy to traverse. here is a simple example how to write this:

#region All code related flying
//all codes go here
#endregion

#region All code about eating
//codes go here
#endregion

Using region directive in .NET

notice the above image, no matter how long the class is, if you organize that is some such regions, you will find more comfortable to work with them time to time. Finding a code block also becomes super easy.

in the similar way, the ‘if’ directive helps you to create some extra code segments of code for a particular condition. Suppose, you need to execute some code in debug mode, but not in release mode. Here this directive will be very helpful.

#if DEBUG
//debug code goes here
#endif

Another interesting thing here is, this will show you whether the code block is currently active or not. Such as, if you are in debug mode and using code like above, the inner codes will be normal like other codes. But, if you change settings to release mode, this code block will become gray, like commented code, mentioning this won’t be executed in current settings.

Downgrade Projects From Visual Studio 2010 To Visual Studio 2008:

This is a scenario, when you may don’t have updated visual studio on your PC but need to open solution(s)/project(s) created on updated version. Luckily, downgrading visual studio 2010 to visual studio 2008 is pretty straight forward/easy. open your solution file(with .sln extension) in notepad or similar editor, find the visual studio version at the top of the file, which should be ‘11.0’ and change that to ’10’. Also, change the ‘visual studio 2010’ to ‘visual studio 2008’ also. And you are done. The solution and related projects will now be opened in visual studio 2008 easily. This worked for me very well, without any issue. If you are having any issue while doing this, let me know details via commenting, I will try to get a solution asap and refine this section.

For your information, I will be extending this article day to day to add other related tips as well. So, if you have any similar .net tips and tricks in mind, please let me know by commenting on this article or via contact page. I will try to attend them and integrate on this article as soon as I can. Happy coding 🙂 .

Share If Liked

  • Click to share on Facebook (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Pinterest (Opens in new window)
  • Click to share on Reddit (Opens in new window)
  • Click to share on Tumblr (Opens in new window)
  • Click to share on Pocket (Opens in new window)

You may also like

Filed Under: Development Tagged With: .net, tips

About Rana Ahsan

Rana is a passionate software engineer/Technology Enthusiast.
Github: ranacseruet

Reader Interactions

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 3,774 other subscribers

Follow Us

  • Twitter
  • Facebook

Top Posts & Pages

  • How To Work With JSON In Node.js / JavaScript
    How To Work With JSON In Node.js / JavaScript
  • PHP HTML5 Video Streaming Tutorial
    PHP HTML5 Video Streaming Tutorial
  • How To Work With C# Serial Port Communication
    How To Work With C# Serial Port Communication
  • Facebook C# API Tutorials
    Facebook C# API Tutorials
  • LinQ Query With Like Operator
    LinQ Query With Like Operator
  • Using Supervisord Web Interface And Plugin
    Using Supervisord Web Interface And Plugin
  • Get Facebook C# Api Access Token
    Get Facebook C# Api Access Token
  • Getting Started With UDP Programming in Java
    Getting Started With UDP Programming in Java
  • Utilizing Config File In C#.NET Application
    Utilizing Config File In C#.NET Application
  • Generate HTTP Requests using c#
    Generate HTTP Requests using c#

Recent Posts

  • Building Auth With JWT – Part 2
  • Building Auth With JWT – Part 1
  • Document Your REST API Like A Pro
  • Understanding Golang Error Handling
  • Web Application Case Studies You Must Read

Tags

.net angularjs apache api audio auth authenticatin aws c# cloud server codeigniter deployment docker doctrine facebook git github golang htaccess html5 http javascript jwt linq mysql nodejs oop performance php phpmyadmin plugin process python regular expression scalability server smarty socket.io tfs tips unit-test utility web application wordpress wpf

Footer

Archives

Follow Us

  • Twitter
  • Facebook

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 3,774 other subscribers

Copyright © 2023