0

enter image description here

What is the mean of this file with 3 blocks in bottom left?

Why the Trace.cs file icons is different from Program.cs?

There is a similar question about this question, but the current situation doesn't seem to be the same as this answer. Please see, enter link description here

2

1 Answer 1

1

The answer provided in that other question is wrong. It has nothing to do with spanning multiple files. There are other icons used for other specific types that can also span multiple files. Any class can span multiple files with partial classes. Some will be grouped in Solution Explorer by default, as they are expected to span multiple files by default, but there are extensions that enable others to be grouped based on the file name without extensions. Also, that icon will be used for certain types even if they don't span multiple files.

That icon actually represents a component. It may represent other more specific types too, but they will all be specialised components. As an example, I just added four classes to a project like so:

internal class MyClass
{
}
internal class MyComponent
{
}
internal class MyControl
{
}
internal class MyForm
{
}

and this is what I saw in the Solution Explorer:

enter image description here

I then updated the last three classes as the names suggest like so:

internal class MyComponent : Component
{
}
internal class MyControl : Control
{
}
internal class MyForm : Form
{
}

and this is what I saw in the Solution Explorer:

enter image description here

I think that controls had a different icon in some older versions of VS but they are using the same as other components now. I also tried adding an item of type Windows Service. That used the same icon and ServiceBase also inherits Component.

You can check the big icon for the Component Class item template in the Add New Item dialogue and then look for other item templates with the same icon. I believe you'll find that they are all specialised components. Interestingly, I just tried adding a Custom Control and it has a different big icon in the dialogue but it has the same small icon in the Solution Explorer.

2
  • Thank you. Your answer is very valuable. When a csharp class implements a special interface of extend a special class, the icon of this file will change to icon with 3 blocks. But I still don't know what kind of interface of class will trigger this change.
    – Xin Zhang
    Commented Aug 10, 2022 at 7:28
  • @XinZhang, yeah you do, because I told. They're components, i.e. they inherit Component. Strictly speaking, any class that implements IComponent is a component, but the Component class provides a default implementation and that class will be inherited in the vast majority of cases. It's inheriting that class, or one derived from it, that will cause that icon to be used, unless another is specified for a more specific type.
    – John
    Commented Aug 10, 2022 at 7:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.