C# Terminology

Hi. This is probably a slightly more advanced, yet trivially academic question.

I’m fairly new to the C# world but have a very strong background in C++. I was quite surprised when I was doing quiz 2 and got to the question about how to declare a function, only to find out I got the answer wrong.

In C++, there’s a very clear and important distinction between “declaring” something and “defining” it. Does this distinction not exist in C#? Can the two terms be used interchangeably?

Hi Robbie,

Usually, when you declare something in C#, you also define it because everything has got a default value. At least in this course.

Here is an example which could be helpful for you. I don’t know how exactly C++ works and what one has to do. In C#, we usually do not need to distinguish between declarations and definitions.

In C#, we have interfaces, though. In an interface, you can declare variables and methods but you cannot define them. You have to define them in a class where you implement the interface. We don’t use interfaces in this course. That’s the only example that comes into my mind where we need the distinction.

C# also does not have the header files where you would declare a function. It is a kind of a one step process

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms