SShortSingh.
Back to feed

C# Generics and Collections Explained: Key Concepts for Technical Interviews

0
·1 views

Generics and collections are among the most frequently tested topics in C# technical interviews, appearing consistently across junior to senior levels. Before generics, developers had to choose between duplicating classes for each type or using the base object type, both of which carried significant drawbacks including lost type safety and boxing overhead. Generic classes and methods solve this by allowing type parameters to be specified at the point of use, enabling a single implementation to work across multiple types while maintaining compile-time safety. Constraints such as where T : class or where T : IComparable further refine generics by restricting which types are permissible, ensuring required capabilities are available within generic code. A practical example is a generic repository pattern over Entity Framework Core, where a single constrained generic class can handle multiple entity types without redundant implementations.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Standard AI Agent Monitoring Scores Are Misleading, New Benchmark Reveals

A developer building a benchmark for AI agent monitoring found that the standard scoring method is easily gamed, with a random coin flip achieving an F1 score of 0.88 under conventional evaluation. The flaw stems from rewarding early detections on normal steps, making trigger-happy monitors appear highly accurate. After revising the metric to count only the first detection on an actual drift step as a true positive, the coin flip score dropped to 0.19, exposing how poorly existing monitors perform. A new dataset of 513 trajectories — covering five hidden drift types including tool-call misuse and goal shift — was created to test monitors against complete, labeled agent runs. Results showed that even the best-performing verifier missed 87.2% of adversarial traces, suggesting current AI agent monitors are far less reliable than standard benchmarks imply.

0
ProgrammingDEV Community ·

Dev Builds Bare-Metal GUI for Custom OS Using UEFI Framebuffer and Double Buffering

A developer working on V.E.L.O.C.I.T.Y.-OS, a bare-metal operating system designed to run inside a CPU's L3 cache, has implemented a graphical user interface after previously relying solely on a text-based serial terminal. The new GUI layer, called Synaptic Canvas, is built on top of the UEFI Graphics Output Protocol framebuffer and uses a double-buffering technique to eliminate screen flicker. Three swappable interface modes were created, including a glassmorphic shell overlay, a Matrix-style rain animation, and a spatial node-based workspace where files and execution blocks appear as floating interactive objects on a 2D plane. All three interfaces are implemented in Rust's no_std environment, meaning they operate without standard float libraries. This marks Part 10 of a planned 12-part series, with upcoming installments set to cover multi-agent scheduling and eventual self-optimization via a local language model.

0
ProgrammingDEV Community ·

The Number 1 Is the Universal Tipping Point for Epidemics, Brains, and Reactors

A single mathematical threshold — the number one — governs whether vastly different systems grow or collapse, from nuclear chain reactions to disease outbreaks to self-sustaining chemical networks. The concept originates from branching process theory, first formalized by Galton and Watson in the 1870s to study the extinction of family surnames. In epidemiology, this threshold appears as R₀, the average number of people each infected person passes a disease to, with an outbreak growing only when R₀ exceeds one. The same logic explains why random networks suddenly form a single connected web once each node averages more than one link, a phenomenon proved by Erdős and Rényi in 1960. Across physics, biology, and chemistry, the behavior of complex systems pivots sharply on whether this average sits just above or just below one.

0
ProgrammingDEV Community ·

How Crypto Scam Site crookcrypto.xyz Drained Users of Nearly $2,900

A fraudulent platform called crookcrypto.xyz has been identified as a crypto scam that deceived at least one user out of $2,890.35 by posing as a legitimate decentralized finance utility. The site mimicked professional crypto exchange interfaces, complete with live-looking charts and dashboards, to build false trust with visitors. When users connected their wallets, they unknowingly signed malicious smart contracts that either granted the scammers full token access or immediately drained their funds. Victims attempting to withdraw were then pressured into paying fabricated 'verification fees' or 'taxes' in a repeating cycle designed to extract more money. Because blockchain transactions are irreversible and funds are quickly routed through mixing services, recovery is extremely difficult once the scam is complete.

C# Generics and Collections Explained: Key Concepts for Technical Interviews · ShortSingh