wasAsked.

What is the difference between C# and .NET?

Frequently Asked (All Companies) · Role not specified · technical

Published

Year not specified · C#, .NET

Community answers

Posted by wasAsked editorial collection

C# is a programming language. .NET is the platform (runtime, libraries and tools) on which C# programs run. C# - A modern, object-oriented, type-safe language created by Microsoft (Anders Hejlsberg) and first released in 2002. - Defines syntax and features: classes, interfaces, generics, LINQ, async/await, pattern matching, records, nullable reference types and more. New versions arrive yearly alongside .NET (for example C# 14 with .NET 10, C# 15 with .NET 11). - C# source code is compiled by the Roslyn compiler into Intermediate Language (IL). .NET - The developer platform that runs and supports that code: - Runtime (CLR): executes IL with JIT compilation (or ahead-of-time compilation with Native AOT), garbage collection, type safety, exception handling, threading. - Base Class Library: collections, file I/O, networking, JSON, cryptography, threading and much more. - Application frameworks: ASP.NET Core (web and APIs), Entity Framework Core (data access), Windows Forms and WPF (desktop), .NET MAUI (mobile and desktop), Blazor, worker services. - SDK and tools: dotnet CLI, NuGet package manager, MSBuild. - .NET supports several languages: C#, F# and Visual Basic. All compile to IL and can use the same libraries. Analogy: C# is the language you write in; .NET is the engine, toolbox and operating environment that runs it — similar to how Java the language runs on the JVM with the Java standard library. Version names to know - .NET Framework: the original Windows-only platform (up to 4.8.1). - .NET Core 1.0–3.1: the cross-platform rewrite. - .NET 5 and later: the unified platform simply called ".NET" (.NET 8 and .NET 10 are LTS versions). Example showing both: // C# code var numbers = new List<int> { 5, 3, 8 }; var sorted = numbers.Order().ToList(); // List<T> and LINQ come from .NET libraries Console.WriteLine(string.Join(", ", sorted)); The syntax (var, lambda, method calls) is C#; List<T>, LINQ's Order and Console come from the .NET class libraries; execution and memory management are handled by the .NET runtime. Why the distinction matters - Language features depend on the compiler version (LangVersion); library and runtime features depend on the target framework (net8.0, net10.0). - You can use the same .NET libraries from F# or VB.NET, and you can run C# only where a .NET runtime (or Native AOT output) is available. Interview summary: "C# is the language; .NET is the runtime, libraries and tooling platform that compiles, runs and supports C# applications across Windows, Linux and macOS."

Ravindra Wadile · · 0 likes

Sign in to add your answer

Related interview topics