80 how do events raise events can be raised only from

This preview shows page 5 - 7 out of 11 pages.

80. How do events raise? Events can be raised only from the declaring class. Users of events can only remove and add methods the invocation list. 81. How do lambda expressions function? Lambda expressions, also known as anonymous methods, use the =>operator and form a compact way of creating inline methods 82. How do we define a lambda expression? Lambda basic definition: Parameters => Executed code. n => n % 2 == 1 FE: List<int> numbers = new List<int>{11,37,52}; List<int> oddNumbers = numbers.where(n => n % 2 == 1).ToList(); //Now oddNumbers is equal to 11 and 37 83. How do you cancel Parallelism? Break or Stop 84. How do you customize events? You can customize events by adding a custom event accessor and by directly using the underlying delegate type 85. How many methods is a multicast delegate going to call? int invocationCount = del.GetInvocationList().GetLength(); 86. HResult Describing severity error 87. IEnumerator GetEnumerator(); The GetEnumeratormethod should return an enumerator object that implements the System.Collections.IEnumeratorinterface. The enumerator object is used for stepping through (enumerating) the elements of the collection. The IEnumeratorinterface specifies the following property and methods: object Current { get; } bool MoveNext(); void Reset(); 88. if-else You can use the if-else statement to execute code depending on a specific condition. 89. Implicit conversion Conversion is allowed and safe to convert. int I = 42 double d = I; 90. Important rule for async and await. You should never have a method marked async without await statements. You should also avoid returning void from an async method except when it's an event handler. 91. Important steps when adding a method to your own type: 1. Choose a name for your method. 2. Decide which data should be passed to your method. 3. Decide which data you want to return to the caller. 4. Decide on the visibility of your method. 92. Indexer For Example List<int> mylist = new List<int> (){1,2,3}; myList[0] = 1; enables instances of your class or struct to be used as arrays 93. InnerExeption Linking two exceptions. 94. Instantiated delegate Object that you can pass around and give it as an argument to other methods. 95. Interlocked class Making operations atomic. Interlocked.Increment. Interlocked.Decrement. You can use the Interlockedclass to execute simple atomic operations. 96. Interlocked.CompareExchange Check first if expected value is there and then replace it. 97. Interlocked.Exchange Switching values: Retrieves current value and replaces it
Image of page 5

Subscribe to view the full document.

98. is operator You can use the is operator to verify that the type of an object is what you expect it to be 99. Iterating across collections Int[] values = { 1,2,3}; For (int index = 0; index < values.length; index++) {console.Write(values[index]);} For(initial; condition; loop) 100. Jump statement: goto, break, continue - You cannot make a jump to a label that's not in scope. - If possible avoid jump statements (refactoring: you can remove them) - Goto >> bad practice >> avoid 101.
Image of page 6
Image of page 7

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern