Questions tagged [.net]

Do NOT use for questions about .NET Core - use [.net-core] instead. The .NET framework is a software framework designed mainly for the Microsoft Windows operating system. It includes an implementation of the Base Class Library, Common Language Runtime (commonly referred to as CLR), Common Type System (commonly referred to as CTS) and Dynamic Language Runtime. It supports many programming languages, including C#, VB.NET, F# and C++/CLI.

The .NET Framework is not specific to any programming language. Programming languages from Microsoft, like , , CLI, and , as well as many other languages from other vendors, all use the same .NET Framework.

The .NET Framework includes a large library of functions as part of the Base Class Library (BCL), including those related to user interface design, data access, database connectivity, cryptography, development of web applications, mathematical algorithms, and network communications. This extensive library simplifies development and makes it easy to rapidly develop new applications.

As such, questions like "How do I do file I/O in C#?" should really be "How do I do file I/O with .NET?". Because such a question concerns the file I/O libraries provided by the .NET Framework, it should be tagged with both the tag, and with the tag, to indicate that you'd like the answer to be written in the C# programming language.

See also: , (do NOT use the tag for questions about .NET Core).

Getting help

Versions of .NET

Performance

Garbage collector

Free .NET Programming Books (C# / F# / VB / Nemerle / Visual Studio)

Reference Source

API Guide


Database

Database Drivers

  • MySQL Connector - Connector/Net is a fully-managed ADO.NET driver for MySQL
  • Npgsql - .NET data provider for PostgreSQL
  • MongoDB - Official MongoDB C# driver
  • RethinkDb.Driver - A RethinkDB database driver in C# striving for 100% ReQL API compatibility and completeness.
  • ServiceStack Redis - .NET's leading C# Redis client
  • StackExchange Redis - General purpose Redis client from Stack Exchange
  • Cassandra - DataStax .NET driver for Apache Cassandra
  • Couchbase - Official Couchbase .NET client library, based on the Enyim Memcached client
  • Firebird.NET - The .NET Data provider is written in C# and provides a high-performance, native implementation of the Firebird API

Useful .NET Libraries

Mathematics

  • Math.NET Numerics - special functions, linear algebra, probability models, random numbers, interpolation, integral transforms and more

Package managers for external libraries

  • NuGet (formerly known as NuPack) - Microsoft (developer-focused package management system for the .NET platform intent on simplifying the process of incorporating third-party libraries into a .NET application during development)

Build Tools

  • Prebuild - Generate project files for all Visual Studio versions, including major IDEs and tools like SharpDevelop, MonoDevelop, NAnt and Autotools

Dependency Injection/Inversion of Control

Logging

Validation

Design by Contract

Compression

Ajax

Data Mapper

ORM

Charting/Graphics

PDF Creators/Generators

Unit Testing/Mocking

Automated Web Testing

Misc Testing/Quality Support/Behavior Driven Development (BDD)

URL Rewriting

Web Debugging

  • Glimpse - Firebug for your webserver

Controls

MS Word/Excel Documents Manipulation

  • DocX to create, read, manipulate formatted word documents. Easy syntax, working nicely, actively developed. No Microsoft Office necessary.
  • Excel XML Writer allows creation of .XLS (Excel) files. No Microsoft Office necessary. It has been a while since it has been updated. It also provides a code generator to create code from already created XLS file (saved as XML). Haven't tested this but looks very promising. The author hasn't updated this in awhile.
  • Excel Reader allows creation/reading of .XLS (Excel) files. No Microsoft Office necessary. It has been awhile since it has been updated.
  • Excel Package allows creation/reading of .XLSX (Excel 2007) files. No Microsoft Office necessary. The author is gone, so it's out of date.
  • EPPlus is based on Excel Package and allows creation/reading of .XLSX (Excel 2007). It is actually the most advanced even comparing to NPOI.
  • NPOI is the .NET version of POI Java project at https://poi.apache.org/. POI is an open source project which can help you read/write Excel, Word, and PowerPoint files. Latest sources available at GitHub repository

Serialization

  • sharpSerializer - XML/binary serializer for WPF, ASP.NET AND Silverlight
  • protobuf-net - .NET implementation of Google's cross-platform binary serializer (for all .NET platforms)

Machine learning

  • Encog C# - Neural networks
  • AForge.net - AI, computer vision, genetic algorithms, machine learning

Chat room

Chat about .NET with other Stack Overflow users

RESTFul Web Services

  • RestSharp - Simple REST and HTTP API Client for .NET

Unclassified

333813 questions
757
votes
14 answers

How do I convert an enum to a list in C#?

Is there a way to convert an enum to a list that contains all the enum's options?
newWeb
749
votes
29 answers

Encrypt and decrypt a string in C#?

How can I encrypt and decrypt a string in C#?
NotDan
  • 31,709
  • 36
  • 116
  • 156
749
votes
35 answers

Implementing INotifyPropertyChanged - does a better way exist?

Microsoft should have implemented something snappy for INotifyPropertyChanged, like in the automatic properties, just specify {get; set; notify;} I think it makes a lot of sense to do it. Or are there any complications to do it? Can we ourselves…
P.K
  • 18,587
  • 11
  • 45
  • 51
743
votes
9 answers

What's the @ in front of a string in C#?

This is a .NET question for C# (or possibly VB.net), but I am trying to figure out what's the difference between the following declarations: string hello = "hello"; vs. string hello_alias = @"hello"; Printing out on the console makes no…
Klaw
  • 7,519
  • 3
  • 18
  • 11
742
votes
16 answers

Array versus List: When to use which?

MyClass[] array; List list; What are the scenarios when one is preferable over the other? And why?
G S
  • 35,511
  • 22
  • 84
  • 118
739
votes
5 answers

C# Equivalent of SQL Server DataTypes

For the following SQL Server datatypes, what would be the corresponding datatype in C#? Exact Numerics bigint numeric bit smallint decimal smallmoney int tinyint money Approximate Numerics float real Date and…
George Stocker
  • 57,289
  • 29
  • 176
  • 237
738
votes
39 answers

What is the correct way to create a single-instance WPF application?

Using C# and WPF under .NET (rather than Windows Forms or console), what is the correct way to create an application that can only be run as a single instance? I know it has something to do with some mythical thing called a mutex, rarely can I find…
Nidonocu
  • 12,476
  • 7
  • 42
  • 43
731
votes
20 answers

Best way to parse command line arguments in C#?

When building console applications that take parameters, you can use the arguments passed to Main(string[] args). In the past I've simply indexed/looped that array and done a few regular expressions to extract the values. However, when the commands…
Paul Stovell
  • 32,377
  • 16
  • 80
  • 108
730
votes
47 answers

MetadataException: Unable to load the specified metadata resource

All of a sudden I keep getting a MetadataException on instantiating my generated ObjectContext class. The connection string in App.Config looks correct - hasn't changed since last it worked - and I've tried regenerating a new model (edmx-file) from…
J. Steen
  • 15,470
  • 15
  • 56
  • 63
717
votes
18 answers

How do I get the current username in .NET using C#?

How do I get the current username in .NET using C#?
Yves
  • 12,059
  • 15
  • 53
  • 57
715
votes
18 answers

Embedding DLLs in a compiled executable

Is it possible to embed a pre-existing DLL into a compiled C# executable (so that you only have one file to distribute)? If it is possible, how would one go about doing it? Normally, I'm cool with just leaving the DLLs outside and having the setup…
Merus
  • 8,796
  • 5
  • 28
  • 41
710
votes
31 answers

How to check if a number is a power of 2

Today I needed a simple algorithm for checking if a number is a power of 2. The algorithm needs to be: Simple Correct for any ulong value. I came up with this simple algorithm: private bool IsPowerOfTwo(ulong number) { if (number == 0) …
configurator
  • 40,828
  • 14
  • 81
  • 115
709
votes
11 answers

Which method performs better: .Any() vs .Count() > 0?

in the System.Linq namespace, we can now extend our IEnumerable's to have the Any() and Count() extension methods. I was told recently that if i want to check that a collection contains 1 or more items inside it, I should use the .Any() extension…
Pure.Krome
  • 84,693
  • 113
  • 396
  • 647
707
votes
20 answers

C# difference between == and Equals()

I have a condition in a silverlight application that compares 2 strings, for some reason when I use == it returns false while .Equals() returns true. Here is the code: if (((ListBoxItem)lstBaseMenu.SelectedItem).Content.Equals("Energy Attack")) { …
Drahcir
  • 12,311
  • 19
  • 63
  • 76
694
votes
9 answers

Difference between InvariantCulture and Ordinal string comparison

When comparing two strings in c# for equality, what is the difference between InvariantCulture and Ordinal comparison?
Kapil
  • 9,469
  • 10
  • 40
  • 53