Skip to main content
ProductsDesktop toolsTASTECADDrawing reviewTASTEFILESFile managementTASTEFTPFile transferTASTESSHRemote workspaceTASTEZIPCompression and extractionTASTEWINMFile managementDeveloper toolsTASTECODERust integrated development environmentTASTESTUDIOIntegrated development and test environmentTASTEETLData integration (ETL)ServersTASTEREMOTERemote desktop serverTASTEGEOGeospatial serverTASTEMAILMail workspaceInvestingTASTESTOCKStock auto-trading desktop appGet startedDownloadsDocumentationBuyAll products
Marketplace
News
TechNewsToday's dev newsDeveloper docsProgramming languagesRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWeb front-end frameworksNext.jsReactVue.js · NuxtSvelteKitAngularServer frameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressApp & desktop frameworksTauriFlutterReact NativeElectronAlgorithmsAlgorithm basicsCore algorithmsAdvanced algorithmsPractical algorithms
CommunityProjectsDevelopment logsPromptsAI tool issuesShowcaseCommunity guide
Work with usTech transferWebsite buildDesktop app buildRelease and payment pipelineSales partnerContact
ServicesRemote desktopCustom installer packages
TASTEDEV
Products

Desktop tools

TASTECADComplex drawings, opened with easeTASTEFILESJust the files you need, as fast as possibleTASTEFTPThe tidiest path for your filesTASTESSHA stronger link between you and your serversTASTEZIPPack faster, unpack saferTASTEWINMA keyboard-first file manager with two panes

Developer tools

TASTECODEEdit, build, debug and test Rust apps in one windowTASTESTUDIOFrom editing to remote tests and approved AI fixesTASTEETLMove data while you watch the values

Servers

TASTEREMOTEA remote desktop you run on your own serverTASTEGEORebuilding a GeoServer-compatible geospatial server in RustTASTEMAILTake back control of your email

Investing

TASTESTOCKStock auto-trading that follows the rules you set: when, and what

Get started

DownloadsLatest builds of every productDocsHow to use each productBuySubscriptions and perpetual licencesAll productsEvery product at a glance
All products
MarketplaceNews
Tech

News

Today's dev newsOfficial announcements on languages, frameworks, GitHub and AIDeveloper docsGuides to languages, frameworks and algorithms

Programming languages

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Frameworks

Web front-end frameworksNext.jsReactVue.js · NuxtSvelteKitAngular
Server frameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
App & desktop frameworksTauriFlutterReact NativeElectron

Algorithms

Algorithm basicsComplexity analysis · Sorting · Searching · Basic data structures · Trees and heapsCore algorithmsGraph traversal · Shortest paths & minimum spanning trees · Dynamic programming · Greedy algorithms · Divide and conquer · BacktrackingAdvanced algorithmsString algorithms · Math and number theory · Bit manipulation · Segment trees · Union-findPractical algorithmsCoding interview strategy · LRU cache · Rate limiting · Consistent hashing
All development docs
Community
ProjectsDiscover builders and their workDevelopment logsDecisions and lessons learnedPromptsReusable instructionsAI tool issuesProblems and workarounds for Claude, Codex, GeminiShowcaseFinished resultsCommunity guideHow we build in the open
Work with us
Tech transferNative apps in Rust and eguiWebsite build10 languages, accounts, docs and downloadsDesktop app buildRust and egui, no WebViewRelease and payment pipelineSigning, MSI, deb, rpm, AppImage, hashesSales partnerRecommend us and earn 30%ContactBuilds, partnerships and investment
Services
Remote desktopReach your computer from a browserCustom installer packagesOnly the features you need, settings preloaded
Buy
EN
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Log in
Log in
TASTEDEV

From small tools to better development.

support@tastedev.netSupport TASTEDEV
ProductsProduct lineupBuyDocsDownloadsMarketplaceSupport
CommunityProjectsDevelopment logsPromptsAI tool issuesShowcase
PoliciesAbout usPrivacy policyTerms of serviceSubscription termsRefund policyCommunity guidelines
AccountLog inSign up
Visitors
Today
Yesterday
Total views
Company
GXSOFT
Representative
CHOI YOUNG GU
Business registration number
853-44-00368
Address
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Phone
+82-10-4404-1523
Email
whitecalvin@tastedev.net
Privacy officer
CHOI YOUNG GU

© 2026 TASTEDEVProduct information is based on verified development sources.Released · improving

C# docs
C#
Getting Started with CSyntax BasicsTypes and DataProjects and PackagesErrors and TestingKey Concepts: LINQ, Delegates, and Async
Discussions

C# guide · 3/6

Types and Data

Every C# type is either a value type or a reference type, and that decides what happens when you assign, pass, or compare values. This chapter covers that split, classes, structs, records, properties, common collections, and null safety.

Value Types vs Reference Types

Built-in types such as int, double, bool, decimal, and DateTime, along with any struct or enum, are value types: the variable holds the data itself, so assignment copies it. Classes, string, arrays, and record classes are reference types: the variable holds a reference to an object, so assignment makes two variables point at the same object.

var p1 = new PointStruct { X = 1 };
var p2 = p1;             // copies the value
p2.X = 99;
Console.WriteLine(p1.X); // 1

var c1 = new PointClass { X = 1 };
var c2 = c1;             // copies the reference
c2.X = 99;
Console.WriteLine(c1.X); // 99

struct PointStruct { public int X; }
class PointClass { public int X; }

string is a reference type, but it is immutable and == compares contents, so it behaves like a value. Use structs for small, immutable data such as coordinates; classes are the default otherwise.

Classes and Properties

A class bundles data (fields and properties) with behavior (methods). Public data is exposed through properties rather than raw fields. A property has get and set accessors, so you can add validation later without breaking any calling code.

var account = new Account("Dana") { Number = "110-123-456" };
account.Deposit(500m);
Console.WriteLine($"{account.Owner}: {account.Balance:F2}");

public class Account
{
    private decimal _balance;

    public Account(string owner) => Owner = owner;

    public string Owner { get; }                 // read-only property
    public string? Memo { get; set; }            // auto-implemented property
    public required string Number { get; init; } // must be set at creation, then frozen

    public decimal Balance => _balance;          // computed property

    public void Deposit(decimal amount)
    {
        if (amount <= 0)
            throw new ArgumentOutOfRangeException(nameof(amount), "Deposit must be positive.");
        _balance += amount;
    }
}

An init accessor allows assignment only during object initialization (the { Number = ... } part), and required turns a forgotten assignment into a compile error. Notice that the statements come first and the class declaration follows: in a file with top-level statements, type declarations must come after the statements.

Records

Records are a concise way to declare types whose main job is carrying data. A positional record gets a constructor, read-only properties, value-based equality, and a readable ToString for free.

var a = new Product("Mouse", 25.00m);
var b = new Product("Mouse", 25.00m);

Console.WriteLine(a == b);  // True: same contents means equal
Console.WriteLine(a);       // Product { Name = Mouse, Price = 25.00 }

var onSale = a with { Price = 19.99m }; // copy with one property changed

public record Product(string Name, decimal Price);

A with expression leaves the original untouched and returns a new record with the listed properties replaced. Plain record declares a reference type; write record struct when you want a value type instead.

Collections

The workhorses live in System.Collections.Generic: List<T> and Dictionary<TKey, TValue>. The type parameters in angle brackets let the compiler check what goes in and what comes out.

List<string> langs = ["C#", "F#", "Rust"];   // collection expression
langs.Add("Go");
langs.Remove("F#");
Console.WriteLine($"{langs.Count} items, first: {langs[0]}");

var stock = new Dictionary<string, int>
{
    ["apple"] = 10,
    ["pear"] = 4,
};
stock["plum"] = 7;                  // adds or overwrites

if (stock.TryGetValue("pear", out var pears))
    Console.WriteLine($"Pears in stock: {pears}");

foreach (var (fruit, qty) in stock)
    Console.WriteLine($"{fruit} = {qty}");

Reading a missing key with the indexer throws KeyNotFoundException, so use TryGetValue when a key may be absent. Other handy collections include HashSet<T> for unique items, Queue<T> for first-in-first-out, and Stack<T> for last-in-first-out. Fixed-size data fits naturally in an array such as int[].

Nullable Reference Types

With <Nullable>enable</Nullable> in the project file, the compiler tracks whether reference-type variables might be null. Plain string means "never null", while string? explicitly allows null. Using a maybe-null value without checking it produces a warning.

string? FindNickname(int userId) => userId == 1 ? "Sky" : null;

string? nick = FindNickname(2);

Console.WriteLine(nick?.Length);          // null if nick is null, no exception
Console.WriteLine(nick ?? "(no nickname)"); // fallback value
nick ??= "Guest";                          // assign only when null

if (nick is not null)
    Console.WriteLine(nick.ToUpper());     // compiler knows nick is non-null here

int? age = null;                           // nullable value type
Console.WriteLine(age.HasValue ? age.Value : -1);

?. skips the member access when the target is null, ?? supplies a default, and ??= fills in a value only if one is missing. When you are certain a value isn't null, the null-forgiving operator ! silences the warning, but it performs no runtime check, so use it sparingly.

Summary

  • Assigning a value type copies the data; assigning a reference type copies the reference.
  • Classes combine properties and methods, and init and required express how objects must be created.
  • Records give you value-based equality and non-destructive updates with with.
  • List<T> and Dictionary<TKey, TValue> cover most needs; use TryGetValue for safe lookups.
  • Nullable reference types, together with string?, ?., and ??, catch many null bugs at compile time.
Questions about this chapter?
Previous chapterSyntax BasicsNext chapterProjects and Packages

0 comments

Top commentsNewest first

Sign in · Sign in to leave a comment.