有没有办法改变的构造函数的在Visual Studio中的智能感知列出的顺序? [英] Is there a way to change the order of constructors listed in IntelliSense in Visual Studio?

查看:147
本文介绍了有没有办法改变的构造函数的在Visual Studio中的智能感知列出的顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我定义一个类有多个构造函数,使底层接口是不可改变的,一旦对象实例化。我想一个构造函数是默认构造一个用户类型在Visual Studio中以下时:

I have defined a class with multiple constructors so that the underlying interfaces are immutable once the object is instantiated. I would like one of the constructors to be the "default" constructor for when a user types the following in Visual Studio:

var obj = new MyClass(

Dim obj As New MyClass(

目前,当我去到实例化对象,在构造函数中未列出(在Visual Studio智能感知)在我在我的类中声明的顺序。有没有一种方法,以纪念我的构造,使他们的方法实例在Visual Studio智能感知期间出现在一个特定的顺序?

Currently when I go to instantiate the object, the constructors aren't listed (in Visual Studio IntelliSense) in the order I declared them in my class. Is there a way to mark up my constructors so that their methods appear in a particular order during instantiation in Visual Studio IntelliSense?

推荐答案

有没有一种方法来控制在Visual Studio的智能感知的顺序。如果你有多个构造函数(或方法),在智能感知方面的唯一真正的控制是使用 EditorBrowsable 用合适的<一个href="http://msdn.microsoft.com/en-us/library/system.componentmodel.editorbrowsablestate.aspx">EditorBrowsableState.这使您可以隐藏构造器(或方法)的智能感知,还是只把它显示在高级模式,但不会让你重新排序。

There isn't a way to control the ordering within Visual Studio's Intellisense. If you do have multiple constructors (or methods), your only real control in terms of intellisense is to use EditorBrowsable with the appropriate EditorBrowsableState. This allows you to hide a contructor (or method) in intellisense, or only have it displayed in "advanced" mode, but does not allow you to reorder them.

然而,在这种情况下,如果你打靶.NET 4中,我建议你考虑使用一个构造函数,并利用的named和可选参数的。

However, in this situation, if you're targetting .NET 4, I'd recommend considering using a single constructor, and taking advantage of named and optional arguments.

这篇关于有没有办法改变的构造函数的在Visual Studio中的智能感知列出的顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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