Untitled Deck Flashcards
What is the most popular language for the .NET platform?
“C# is the most popular language for the .NET platform
On what devices can C# programs run?
“C# programs can run on many devices
What kind of language is C#?
“C# is a cross-platform
What are C#’s ecosystem and workload benefits?
“C# has broad support in the ecosystem and is compatible with all .NET workloads.”
What programming principles and paradigms does C# support?
“C# is based on object-oriented principles and incorporates features from other paradigms
What low-level features does C# include?
“C# includes low-level features that support high-efficiency scenarios without requiring unsafe code.”
What are most .NET runtime and libraries written in?
“Most .NET runtime and libraries are written in C#
What is the purpose of the ‘Hello, World’ program in C#?
“The ‘Hello
Write a single-line ‘Hello, World’ program in C# using top-level statements.
”// This line prints ‘Hello
What does a single-line comment in C# look like?
“Single-line comments in C# start with // and continue to the end of the current line.”
What does a multi-line comment in C# look like?
“Multi-line comments in C# start with /* and end with */.”
What does the WriteLine method do?
“The WriteLine method of the Console class produces the output of a program. It is part of the System namespace.”
Write a ‘Hello, World’ program with a Main method in C#.
“using System;\n\nclass Hello\n{\n static void Main()\n {\n // This line prints ‘Hello
What does a ‘using’ directive in C# do?
“A ‘using’ directive references a namespace
What is the purpose of namespaces in C#?
“Namespaces provide a hierarchical means of organizing C# programs and libraries.”
What is the role of the static modifier in C# methods?
“The static modifier indicates that a method operates without reference to a particular object
What is the entry point for a C# program without top-level statements?
“The entry point is a static method named Main when there are no top-level statements.”
How does the compiler handle top-level statements in C#?
“When using top-level statements
Where can you start learning C# as a beginner?
“Beginner tutorials and links in C# documentation are good starting points. Experienced developers can also read tips for transitioning from Java
What makes C# approachable for developers?
“C# is approachable for beginners and offers advanced features for experienced developers writing specialized applications. Developers can quickly become productive and learn more specialized techniques as needed.”
What memory management benefit does C# provide?
“C# apps benefit from the .NET Runtime’s automatic memory management and extensive runtime libraries provided by the .NET SDK.”
What are platform-independent libraries in .NET?
“Platform-independent libraries in .NET include file system libraries
What are some workload-specific libraries in .NET?
“Workload-specific libraries include ASP.NET Core web libraries and the .NET MAUI UI library.”
What is NuGet, and how does it relate to C#?
“NuGet is a rich open-source ecosystem that augments the libraries provided by the .NET runtime with additional components.”
How is C# syntax familiar to developers?
“C# syntax is familiar to those who have used C
What type of language is C#?
“C# is a strongly typed language where every variable’s type is known at compile time
What are C#’s fundamental data types?
“C# includes value types like int
What is the purpose of the record modifier in C#?
“The record modifier in C# allows the compiler to synthesize code for equality comparisons for struct or class types.”
What features define C#’s object-oriented behavior?
“C# supports object-oriented techniques like inheritance
What are exceptions in C#, and how are they handled?
“C# uses exceptions to report and handle errors. Exceptions can be thrown to indicate failure and handled using try-catch blocks to recover.”
What is LINQ in C#, and what does it do?
“LINQ (Language Integrated Query) provides a unified syntax to query or transform collections of data regardless of storage type
Write a LINQ query to find students with a GPA greater than 3.5.
“var honorRoll = from student in Students\n where student.GPA > 3.5\n select student;”
What is asynchronous programming in C#, and what keywords does it use?
“Asynchronous programming in C# uses the async and await keywords to write code that reads as though it runs synchronously but executes asynchronously.”
Write a C# method using async to get the length of a web page.
“public static async Task<int> GetPageLengthAsync(string endpoint)\n{\n var client = new HttpClient();\n var uri = new Uri(endpoint);\n byte[] content = await client.GetByteArrayAsync(uri);\n return content.Length;\n}"</int>
What is an await foreach statement in C#?
“The await foreach statement in C# iterates over a collection backed by asynchronous operations
Write an example of an async iterator in C#.
“public static async IAsyncEnumerable<int> ReadSequence()\n{\n int index = 0;\n while (index < 100)\n {\n int[] nextChunk = await GetNextChunk(index);\n if (nextChunk.Length == 0) yield break;\n foreach (var item in nextChunk) yield return item;\n index++;\n }\n}"</int>
How can an async iterator be used in C#?
“await foreach (var number in ReadSequence())\n{\n Console.WriteLine(number);\n}”
What is pattern matching in C#?
“Pattern matching in C# enables you to inspect data and make decisions based on its characteristics using a concise and expressive syntax.”
Write a C# method using pattern matching for a boolean OR operation.
“public static bool Or(bool left