Ask a questionAsk a question
 

General Discussion#Region and #End Region in VB in a method

  • Friday, April 03, 2009 8:09 AMDTeubner Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi All,
    I am very new to VB as my team manger ask me to code in VB instead of C# and I am not sure is this is a silly question. Anyway:

    I like the use of #region in c# also in a method to make the code a little more readable. But it was not possible to use it in VB. I hoped this could change in the next version but I tried it in CTP and get the same message.

    I would like to suggest this or an alternative to the new VB version. This should be implemented that other users on other systems using my codefile could also collaps the code part and see my comment to it.

    If this is really a stupid question please let me know an alternative currently working.

    Thanks
    Daniel

All Replies

  • Friday, April 03, 2009 9:57 AMRory Becker Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hey Daniel...

    I don't work for MS and I am in no position to influence this I'm afraid.

    However I can tell you what the reasoning for this has been in the past.

    Basically the need to collapse sections of code inside a method is a sign that your method is to complex to be easily maintainable.

    Generally it is suggested that you Refactor your code to break it into several smaller methods.

    I realise that this is probably not the answer you're looking for. Perhaps this will make it's way into the language. I can't say for sure.

    If you're looking for a tool to help in the refactoring, I would recommend RefactorPro. I use it all the time and find it to be very useful.

    I hope this was of some use to you :)