문제

I'm new in C# and what I learned at school it's really poor. Last week I came to the same problem, I didn't know what the ? means after a name type in C#. I could find the answer, then again what does "??" means in a expression, I'm really frustrated.

In this case the star (*) what is telling me about the incoming parameter? (I'm into an unsafe code block)

I'll really thanked if you give me some quick guides about this things in C#.

도움이 되었습니까?

해결책

* after a type determines a pointer. There's a good chance that you may never even need to use this.


? after a type says that it is nullable. See below:

int? a = null;
int b = null; //Compile error

?? is the null coalescing operator. Basically it will give you the right-hand side value if the left-hand side is null.

object a = null;
object b = new Object();
object c = a ?? b;
// 'c' is 'b' because 'a' was null.

I hope that answers your questions. I couldn't tell if you were asking about all of these or only the *.

다른 팁

'*' means that it is a pointer, much liker pointers in C. You will very rarely encounter these in C# code.

that's how you can declare pointer type, you better read Pointer types (C# Programming Guide)

Pointers are In an unsafe context

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top