Xin Zhang
Xin Zhang

Reputation: 1

What is this C# file icon with three blocks which is found in Visual Studio?

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

Upvotes: 0

Views: 487

Answers (1)

John
John

Reputation: 3182

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.

Upvotes: 1

Related Questions