I've encountered this operator in C# when dealing with custom events: MyEvent?.Invoke(this, new EventArgs());
. What is the purpose of the ?.
portion of this statement?
Asked
Active
Viewed 98 times
0

JTW
- 3,546
- 8
- 35
- 49
-
Yup, definitely a dup. For some reason that question didn't come up when I searched... the syntax seems to bugger up the search engine for some reason. – JTW Apr 20 '17 at 01:25
-
1Yeah, it's hard to find what operators mean in C#. The best place to look is the [MSDN article](https://msdn.microsoft.com/en-us/library/6a71f45d.aspx) then at least you get the right name to search for. – Steve Apr 20 '17 at 01:28
1 Answers
-1
It's making sure it's not null. They have these in swift and their called optionals. If the variable is null then it returns null

Cameron Monks
- 107
- 1
- 7
-
It most definitely is not an option type, it's a null coalescing operator. – Rob Apr 20 '17 at 01:40