473,807 Members | 2,853 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

closing } automatically

Does anyone know a way to make the IDE close braces in Ifs statements
(methods also) for C# ?
In VB.NET you have an automatic closing...
Aug 10 '06 #1
3 1420
If your using VS.NET 2005 you can just type the word "if" and then hit tab. "if" is a built-in code snippet. You can write your
own code snippets if you'd like and place them in your "My Documents/Visual Studio 2005/Code Snippets" folder. VS.NET picks them up
without even having to restart the IDE.

If your using an older version I think you might be out of luck. Maybe you could write an addin and assign it to a specific
keyboard shortcut, but I'm not sure how difficult that would be.

--
Dave Sexton

"Bruce One" <ra**@virtualso ftware.com.brwr ote in message news:50******** *************** ***********@mic rosoft.com...
Does anyone know a way to make the IDE close braces in Ifs statements
(methods also) for C# ?
In VB.NET you have an automatic closing...

Aug 11 '06 #2
Thats true, this snippet code may help in If statements...
But what about when we write a new method ? Then we have to write the 2
parenthesis and after the 2 braces...its not possible to let IDE fill it for
us, like in VB.NET right?

"Dave Sexton" wrote:
If your using VS.NET 2005 you can just type the word "if" and then hit tab. "if" is a built-in code snippet. You can write your
own code snippets if you'd like and place them in your "My Documents/Visual Studio 2005/Code Snippets" folder. VS.NET picks them up
without even having to restart the IDE.

If your using an older version I think you might be out of luck. Maybe you could write an addin and assign it to a specific
keyboard shortcut, but I'm not sure how difficult that would be.

--
Dave Sexton

"Bruce One" <ra**@virtualso ftware.com.brwr ote in message news:50******** *************** ***********@mic rosoft.com...
Does anyone know a way to make the IDE close braces in Ifs statements
(methods also) for C# ?
In VB.NET you have an automatic closing...


Aug 11 '06 #3
Hi Bruce,

You can write your own snippets, as I suggested. VS.NET 2005 even gives you intellisense for the XML schema. It really is simple.

Here's a snippet that you can name, "method.snippet " and place in your My Documents/Visual Studio 2005/Code Snippets folder. Extend
it all you want.

For now it generates the following method stub:

public $return$ $name$()
{
$end$
}

[void] is an input parameter that VS.NET 2005 treats as an input box. Tab through each input box and enter the appropriate data,
with the exception of [end]. Press the 'Enter' key when you are finished filling in the variables. [end] is where the cursor is
placed after you hit 'Enter'.

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microso ft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Public Parameterless Method</Title>
<Shortcut>metho d</Shortcut>
<Description>St ubs out a simple, public method without any parameters.</Description>
<Author>Copyrig ht (c) 2006 Dave Sexton</Author>
<SnippetTypes >
<SnippetType>Ex pansion</SnippetType>
<SnippetType>Su rroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations >
<Literal Editable="true" >
<ID>return</ID>
<Default>void </Default>
</Literal>
<Literal Editable="true" >
<ID>name</ID>
<Default>Method Name</Default>
</Literal>
</Declarations>
<Code Language="cshar p">
<![CDATA[public $return$ $name$()
{
$end$
}]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>

--
Dave Sexton

"Bruce One" <ra**@virtualso ftware.com.brwr ote in message news:54******** *************** ***********@mic rosoft.com...
Thats true, this snippet code may help in If statements...
But what about when we write a new method ? Then we have to write the 2
parenthesis and after the 2 braces...its not possible to let IDE fill it for
us, like in VB.NET right?

"Dave Sexton" wrote:
>If your using VS.NET 2005 you can just type the word "if" and then hit tab. "if" is a built-in code snippet. You can write your
own code snippets if you'd like and place them in your "My Documents/Visual Studio 2005/Code Snippets" folder. VS.NET picks them
up
without even having to restart the IDE.

If your using an older version I think you might be out of luck. Maybe you could write an addin and assign it to a specific
keyboard shortcut, but I'm not sure how difficult that would be.

--
Dave Sexton

"Bruce One" <ra**@virtualso ftware.com.brwr ote in message news:50******** *************** ***********@mic rosoft.com...
Does anyone know a way to make the IDE close braces in Ifs statements
(methods also) for C# ?
In VB.NET you have an automatic closing...



Aug 11 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3950
by: Jean-Fran?ois Lacrampe | last post by:
Hello, I want to write a _very_ simple text parser that would replace a string like: "This is text with /italics/, *bold* and _underline_." and generate automatically something like this: "This is text with <i>italics</i>, <b>bold</b> and <span
4
1781
by: James | last post by:
Quick question about closing recordsets and connection objects. We're in the process of rewriting a TON of bad code. None of it is even remotely tabbed properly, it's impossible to read half the time and it never closes connection objects or recordsets. Unfortunately, I've been assigned the task of closing them. I assume I'm just doing: recordset.close Set recordset = Nothing conn.close
2
2522
by: Ron L | last post by:
I have an MDI application which opens a number of child windows, each of which could have data in a state that needs to be saved. Each child window catches its Closing event and cancels it if the user wants to save the data, but when the Application closes this event isn't thrown automatically. I added a loop to close each child window, but can't seem find how to catch the child window's cancel of the Closing event, so even if the user...
102
5752
by: Skybuck Flying | last post by:
Sometime ago on the comp.lang.c, I saw a teacher's post asking why C compilers produce so many error messages as soon as a closing bracket is missing. The response was simply because the compiler can't tell where a bracket is missing.... a few weeks have past, I requested a feature for the delphi ide/editor "automatic identation of code in begin/end statements etc" and today when I woke up I suddenly released a very simple solution for this...
3
2377
by: Zeng | last post by:
Is there any advantage of always calling SqlConnection's Close method after done using it vs. just let it go out of scope open and hope the garbage collection will take care of it? thanks!
7
1807
by: Tumurbaatar S. | last post by:
Is it so important to close database connections? As I understand, after processing a request and sending a response, page object destroyed. So all used connections also destroyed. Yes?
10
4032
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the application. What should happen, is that the main MDI form should close, taking the child forms with it. There is code to loop through the child forms, remove the controls on each of them, and then close the form, but this code should execute only...
5
15793
by: Oenone | last post by:
I have a VB.NET form which I'm displaying modally using the ShowDialog() method. Within the form is a Cancel button, and I've set this button into the Form's CancelButton property so that pressing Escape automatically clicks the button. Within the button's Click event code I display a confirmation messagebox to ensure the user really does want to cancel. However, regardless of what code I put in this event, the dialog form always...
14
3371
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using VS2005 and .net 2.0. I'm creating an application that has 3 forms. I want allow users to move forward and backward with the forms and retain the data users have entered. I thought I'll make the inactive forms invisible but this is creating a memory corruption problem when user close the form2 or form3 and not the formMain. My main form has a Next button which makes the main form invisible and starts a new form which I'll...
19
3229
by: zacks | last post by:
I have a .NET 2.0 MDI application where the child form has a Tab Control. Each of the Tab in the Tab Control has a Validating event to handle what it should do when the user changes tabs. But these Validating Events are also fired when either the child form or the main (parent) form Close icon is clicked. And I need for these events to know if they are being invoked because the app (or child window) is being closed. I have set a boolean...
0
9599
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10626
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10374
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10112
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5685
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4330
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.