Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8580229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:47:01+00:00 2026-06-11T20:47:01+00:00

In Visual Studio you can use code snippets e.g. when your are editing a

  • 0

In Visual Studio you can use code snippets e.g. when your are editing a class you can type ctor and the default constructor will automaticly be added to your class.
Is it possible to create a code snippet in Visual Studio, that does the following:

  • Creates the get/set Logger property where the cursor is.
  • Adds using Castle.Core.Logging
  • Lets me choose where in the list of instance variables I can place private ILogger _logger = NullLogger.Instance;.
public class Person
{
    private string name;
    private int age;

    public Person()
    {
    }

    // cursor is here and you type "logger"
}

After you type logger visual Studio adds the following code:

using Castle.Core.Logging; // Added by code snippet

public class Person
{
    private string name;
    private ILogger _logger = NullLogger.Instance; // Added by code snippet
    private int age;

    public Person()
    {
    }

    // Added by code snippet
    public ILogger Logger
    {
        get { return _logger; }
        set { _logger = value; }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T20:47:02+00:00Added an answer on June 11, 2026 at 8:47 pm

    There is two great tutorials here How to: Create a Basic Code Snippet & How to: Manage Code Snippets

    The summary is as follows,

    1. Create a .snippet file; this is an XML file that includes the code you want to add, and references. The basic example includes all of the requirements except shortcut.
    2. Import the code snippet into your visual studio instance.
    3. Use to your hearts content

    Happy to throw together an example if you’d like.

    As I’ve created the snippet to test this, you’ll want something as follows. Self evident what you need to edit to suit your needs.

    <?xml version="1.0" encoding="utf-8"?>
    <CodeSnippets
        xmlns="http://schemas.microsoft.com/VisualStudio/2010/CodeSnippet">
      <CodeSnippet Format="1.0.0">
        <Header>
          <Title>
            Log4Net instance using Castle.Core.Logging
          </Title>
          <Shortcut>logger</Shortcut>
        </Header>
        <Snippet>
          <References>
            <Reference>
              <Assembly>Castle.Core.Logging.dll</Assembly>
            </Reference>
          </References>
          <Imports>
            <Import>
              <Namespace>Castle.Core.Logging</Namespace>
            </Import>
          </Imports>
          <Code Language="CSharp">
            <![CDATA[private ILogger _logger = NullLogger.Instance;
            public ILogger Logger
        {
            get { return _logger; }
            set { _logger = value; }
        }]]>
          </Code>
        </Snippet>
      </CodeSnippet>
    </CodeSnippets>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I basically use vim to write some simple C# code snippets. Visual Studio is
On Visual studio I can force use of 32-bit time_t by declaring _USE_32BIT_TIME_T .
I currently use visual studio 2008 for creating projects that can run on windows.
Can I use Microsoft Development Studio (a.k.a. Visual C++ 6), but replacing its awful
In visual studio I can right-click on most things (methods, class instances, local variables...)
I have a stack of code snippets imported into Visual Studio. Just recently, they
Is there an easy way open the parent class code file in visual studio.
I know visual studio has some magic keywords you can use in comments, which
In Visual Studio 2010, I have a Database Project. I can use this without
You know in Visual Studio you can use the += syntax and a couple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.