片段代码在VS2010 Express中创建的构造 [英] Snippet code to create constructor in VS2010 Express

查看:130
本文介绍了片段代码在VS2010 Express中创建的构造的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有准备好使用的代码片段在VS 2010 Express版本(对于C#),来创建与所选属性参数的构造函数?

Is there any ready for use code snippet in VS 2010 Express edition (for C#), to create constructor with parameters from selected properties?

当我创建一个新的类,我已经写了下面的代码:

When I create a new class and I've written following code:

public class FileDetails
{
    public int ID { get; set; }
    public string FileName { get; set; }
    public string FilePath { get; set; }
    public DateTime LastWriteTime { get; set; }
    public FileStatus LastFileStatus { get; set; }
    public NotifyIfFileNotExists NotifyIfFileNotExists { get; set; }
    public string RecepientsEmailList { get; set; }
    public string AdminEmailList { get; set; }

    public FileDetails()
    {
    }
}

我想鼠标选择所有的公共属性(或把一些代码段),产生以下costructor对我来说:

I would like to mouse-select all the public properties (or put some snippet code), that produce following costructor for me:

public FileDetails(int id, string fileName, string filePath, DateTime lastWriteTime, FileStatus lastFileStatus, NotifyIfFileNotExists notifyIfFileNotExists, string recepientsEmailList, string adminEmailList)
{
    this.ID = id;
    this.FileName = fileName;
    this.FilePath = filePath;
    this.LastWriteTime = lastWriteTime;
    this.LastFileStatus = LastFileStatus;
    this.NotifyIfFileNotExists = notifyIfFileNotExists;
    this.RecepientsEmailList = recepientsEmailList;
    this.AdminEmailList = adminEmailList;
}



问:是否有任何现成的解决方案,或者,如果没有,没有任何人已经有一个想法或准备代码是如何实现的?

Question: is there any ready solution for that or, if no, does anyone has got an idea or ready code how to achieve that?

最好的问候,结果
马尔辛 -

Best regards,
Marcin

推荐答案

ReSharper的是你要找的东西。但是没有免费版本。但是,从.NET 3.5可以初始化的属性,而无需为他们每个人一个明确的说法。

ReSharper is what you're looking for. But there's no free version. But from .NET 3.5 you can initialize the properties without having an explicit argument for each of them.

这篇关于片段代码在VS2010 Express中创建的构造的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆