CodeSamplez.com

Programming, Web development, Cloud Technologies

  • Facebook
  • Google+
  • RSS
  • Twitter
  • 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
Home Development Vistual Studio .NET Tips And Tricks

Vistual Studio .NET Tips And Tricks

Rana Ahsan July 13, 2012 Leave a Comment


 Vistual Studio .NET Tips And Tricks    

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 🙂 .

Related

Filed Under: Development Tagged With: .net, tips

About Rana Ahsan

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

Leave a Reply Cancel reply

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

Email Subscription

Never miss any programming tutorial again.

Popular Tutorials

  • PHP HTML5 Video Streaming Tutorial
  • How To Work With JSON In Node.js / JavaScript
  • Generate HTTP Requests using c#
  • How To Work With C# Serial Port Communication
  • Facebook C# API Tutorials
  • How To Work With CodeIgniter Pagination
  • LinQ To SQL Database Update Operations In C#
  • Get Facebook C# Api Access Token
  • How To Work With Multithreaded Programming In C#.NET Application
  • How To Work With Codeigniter Caching In PHP

Recent Tutorials

  • Building Auth With JWT – Part 1
  • Document Your REST API Like A Pro
  • Understanding Golang Error Handling
  • Web Application Case Studies You Must Read
  • Getting Started With Golang Unit Testing
  • Getting Started With Big Data Analytics Pipeline
  • NodeJS Tips And Tricks For Beginners
  • Apple Push Notification Backend In NodeJS
  • Web Based Universal Language Translator, Voice/Text Messaging App
  • How To Dockerize A Multi-Container App From Scratch

Recent Comments

  • intolap on PHP HTML5 Video Streaming Tutorial
  • manishpanchal on PHP HTML5 Video Streaming Tutorial
  • Rana Ghosh on PHP HTML5 Video Streaming Tutorial
  • ld13 on Pipe Email To PHP And Parse Content
  • Daniel on PHP HTML5 Video Streaming Tutorial

Archives

Resources

  • CodeSamplez.com Demo

Tags

.net apache api audio aws c# cache cloud server codeigniter deployment doctrine facebook git github golang htaccess html5 http image java javascript linq mysql nodejs oop performance php phpmyadmin plugin process python regular expression scalability server smarty ssh tfs thread tips ubuntu unit-test utility web application wordpress wpf

Copyright © 2010 - 2021 · CodeSamplez.com ·

Copyright © 2021 · Streamline Pro Theme on Genesis Framework · WordPress · Log in