Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

Array ^

The ^ operator is used for indexing from the end of an array or collection. Specifically, ^1 represents the last element, ^2 represents the second-to-last element,  void Display(int[] s) => Console.WriteLine(string.Join(" ", s)); int[] xs = [0, 0, 0]; Display(xs); ref int element = ref xs[0]; element = 1; Display(xs); element = ref xs[^1]; element = 3; Display(xs); // Output: // 0...

Reference types vs Value types

Both value types and reference types are used to represent data, but they behave differently in terms of memory allocation, assignment, and passing to methods. Memory Allocation: Value Types: Value types are stored directly in memory where they are declared. They typically reside on the stack. Examples of value types include simple types like int, float, char, and structs. Reference Types: Reference...

Sealed Class

The sealed keyword is used to prevent a class from being inherited or to prevent a method from being overridden. When a class is marked as sealed, it means that it cannot be used as a base class for further inheritance. Similarly, when a method is marked as sealed, it means that it cannot be overridden in derived classes. Sealed Class: public sealed class FinalClass { // Class members and...

Exceptions

 https://www.tutorialsteacher.com/csharp/csharp-exception https://blog.naver.com/PostView.naver?blogId=coding-abc&logNo=222388017000&parentCategoryNo=&categoryNo=&viewDate=&isShowPopularPosts=false&from=postView&nb...