4
Answers

Difference between class & type

Ask a question
Hi all,
I'm a newbie in C#, appreciated if someone can clear my doubt on the class & type:

DirectoryInfo is a .net class, we need to instantiate an object to use it as below:

string path = @"C:\My Folder";
DirectoryInfo di = new DirectoryInfo(path);


However, why we also can use this class as a type as shown below:
DirectoryInfo parent = Directory.GetParent(path);



Answers (4)