跳至主要內容
產品桌面工具TASTECAD圖面檢視TASTEFILES檔案管理TASTEFTP檔案傳輸TASTESSH遠端工作空間TASTEZIP壓縮與解壓縮TASTEWINM檔案管理開發工具TASTECODERust 整合開發環境TASTESTUDIO整合開發與測試環境TASTEETL資料整合(ETL)伺服器TASTEREMOTE遠端桌面伺服器TASTEGEO空間資訊伺服器TASTEMAIL郵件工作空間投資TASTESTOCK股票自動交易桌面應用程式開始使用下載文件購買所有產品
市集
資訊
技術資訊今日開發資訊開發文件程式語言RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWeb 前端框架Next.jsReactVue.js · NuxtSvelteKitAngular伺服器框架Spring BootDjangoFastAPIASP.NET CoreNestJS · Express應用程式與桌面框架TauriFlutterReact NativeElectron演算法演算法基礎核心演算法進階演算法實務演算法
社群專案開發日誌提示詞AI 工具問題作品展示社群指南
合作技術傳授網站建置桌面應用程式建置發布與付款流程銷售合作夥伴聯絡我們
服務遠端桌面安裝包客製
TASTEDEV
產品

桌面工具

TASTECAD再複雜的圖面,也能輕鬆開啟TASTEFILES只挑需要的檔案,最快送達TASTEFTP讓檔案往來,走最俐落的路TASTESSH在你與伺服器之間,築起更穩固的連線TASTEZIP壓得更快,解得更安心TASTEWINM以鍵盤為主、用兩個窗格整理檔案的檔案管理器

開發工具

TASTECODE在一個視窗中完成 Rust 應用程式的編輯、建置、偵錯與測試TASTESTUDIO從編輯到遠端測試,再到經核准的 AI 修正TASTEETL邊看數值,邊搬資料

伺服器

TASTEREMOTE在自己的伺服器上運行的遠端桌面TASTEGEO以 Rust 重新打造相容 GeoServer 的空間資訊伺服器TASTEMAIL把郵件的主導權拿回自己手上

投資

TASTESTOCK何時、做什麼——依你訂下的規則運作的股票自動交易

開始使用

下載所有產品的最新版本文件各產品使用方法購買訂閱與永久授權所有產品一覽全部產品
所有產品
市集資訊
技術

資訊

今日開發資訊語言、框架、GitHub 與 AI 官方發布開發文件語言、框架與演算法指南

程式語言

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

框架

Web 前端框架Next.jsReactVue.js · NuxtSvelteKitAngular
伺服器框架Spring BootDjangoFastAPIASP.NET CoreNestJS · Express
應用程式與桌面框架TauriFlutterReact NativeElectron

演算法

演算法基礎複雜度分析 · 排序 · 搜尋 · 基礎資料結構 · 樹與堆積核心演算法圖形走訪 · 最短路徑與最小生成樹 · 動態規劃 · 貪婪演算法 · 分治法 · 回溯法進階演算法字串演算法 · 數學與數論 · 位元運算 · 線段樹 · 併查集實務演算法程式面試解題策略 · LRU 快取 · 速率限制 · 一致性雜湊
查看全部開發文件
社群
專案探索開發者與作品開發日誌決策與試錯提示詞可重複使用的指令AI 工具問題Claude、Codex、Gemini 的問題與替代做法作品展示已完成的成果社群指南我們如何公開打造
合作
技術傳授用 Rust 與 egui 打造原生應用程式網站建置10 種語言、帳號、文件與下載桌面應用程式建置Rust 與 egui,不用 WebView發布與付款流程簽章、MSI、deb、rpm、AppImage、雜湊銷售合作夥伴推薦即得 30%聯絡我們開發、合作與投資諮詢
服務
遠端桌面用瀏覽器連線你的電腦安裝包客製只裝需要的,設定預先放好
購買
繁
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
登入
登入
TASTEDEV

從小工具到更好的開發。

support@tastedev.net支持 TASTEDEV
產品產品系列購買文件下載市集客戶支援
社群專案開發日誌提示詞AI 工具問題作品展示
政策關於我們隱私權政策服務條款訂閱條款退款政策社群規範
帳戶登入註冊
訪客
今天
昨天
累計瀏覽
公司名稱
GXSOFT
負責人
CHOI YOUNG GU
營業登記號碼
853-44-00368
地址
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
電話
+82-10-4404-1523
電子郵件
whitecalvin@tastedev.net
個人資料保護負責人
CHOI YOUNG GU

© 2026 TASTEDEV產品資訊以經驗證的開發原始碼為準。已發布·持續改進

C# 文件
C#
Getting Started with CSyntax BasicsTypes and DataProjects and PackagesErrors and TestingKey Concepts: LINQ, Delegates, and Async
討論

C# 指南 · 4/6

Projects and Packages

本章目前僅提供英文版。

As a codebase grows, you split it into several projects and start pulling in libraries written by others. .NET organizes this around four units: assemblies, projects, solutions, and NuGet packages. This chapter explains how they fit together, then shows how to reference projects, add packages, and produce output you can ship.

Assemblies, Projects, and Solutions

UnitWhat it is
AssemblyThe compiled output: a .dll library or an executable, containing code plus type metadata.
ProjectOne .csproj file that produces one assembly; it lists sources, target framework, and dependencies.
SolutionA list of projects you build and test together, stored as .sln or the newer XML-based .slnx.
NuGet packageA .nupkg archive of assemblies and metadata, downloaded from a feed such as nuget.org.

Keep namespaces and assemblies apart in your head. A namespace is a logical naming scope; an assembly is a physical unit of deployment. One assembly can contain many namespaces, and a single namespace can span several assemblies.

Creating a Multi-Project Solution

A common layout is an executable, a class library holding the core logic, and a test project, all in one solution. These commands create the skeleton:

mkdir Shop && cd Shop
dotnet new sln -n Shop
dotnet new classlib -o src/Shop.Core
dotnet new console -o src/Shop.Cli
dotnet sln add src/Shop.Core src/Shop.Cli

# let Shop.Cli use the code in Shop.Core
dotnet add src/Shop.Cli reference src/Shop.Core

dotnet build   # from the solution folder, this builds every project

Adding the reference writes an entry like this into Shop.Cli.csproj. At build time the referenced project is compiled first and its assembly is copied into the consumer's output folder.

<ItemGroup>
  <ProjectReference Include="..\Shop.Core\Shop.Core.csproj" />
</ItemGroup>

Access Modifiers Across Assemblies

Only types and members marked public are visible to other projects. internal means visible within the same assembly only, which is how libraries hide implementation details. A top-level type with no modifier defaults to internal.

// src/Shop.Core/PriceCalculator.cs
namespace Shop.Core;

public static class PriceCalculator
{
    public static decimal WithTax(decimal price) => Round(price * (1 + TaxRate));

    internal const decimal TaxRate = 0.1m;   // visible only inside Shop.Core

    private static decimal Round(decimal value) => Math.Round(value, 2);
}
對本章有疑問嗎?
上一章Types and Data下一章Errors and Testing
// src/Shop.Cli/Program.cs
using Shop.Core;

Console.WriteLine($"{PriceCalculator.WithTax(100m):F2}"); // 110.00
// PriceCalculator.TaxRate is internal, so it is not accessible here

If a test project needs to exercise internal members, the library can grant access to that specific assembly with the InternalsVisibleTo attribute.

Using NuGet Packages

NuGet is the package manager for .NET. dotnet add package records a PackageReference in the project file, and packages are restored automatically on the next build.

cd src/Shop.Cli
dotnet add package Humanizer                     # add the latest stable version
dotnet add package Humanizer --version <version> # pin a specific version
dotnet list package                              # show referenced packages
dotnet list package --outdated                   # show packages with newer versions
dotnet remove package Humanizer                  # remove it again
dotnet restore                                   # run the restore step on its own
using Humanizer;

Console.WriteLine("order_created_at".Humanize());        // Order created at
Console.WriteLine(TimeSpan.FromMinutes(95).Humanize(2)); // 1 hour, 35 minutes

Before adopting a package, check its download count, how recently it was updated, its license, and which frameworks it supports. When many projects must agree on package versions, central package management lets you set them once in a Directory.Packages.props file at the solution root, and shared build settings can live in Directory.Build.props.

Publishing

dotnet build output is meant for development. To produce something you can deploy to another machine, use dotnet publish:

# framework-dependent: smaller, but the target machine needs the .NET runtime
dotnet publish src/Shop.Cli -c Release -o out

# self-contained: bundles the runtime, nothing to install on the target
dotnet publish src/Shop.Cli -c Release -r linux-x64 --self-contained -o out-linux

# bundle everything into a single executable file
dotnet publish src/Shop.Cli -c Release -r win-x64 --self-contained -p:PublishSingleFile=true

The -r option takes a runtime identifier (RID) such as win-x64, linux-x64, or osx-arm64. If startup time and memory footprint matter, add <PublishAot>true</PublishAot> to the project to compile ahead of time to native code, though libraries that lean heavily on reflection may not be compatible. To share a library as a NuGet package of your own, run dotnet pack -c Release.

Summary

  • Each project produces one assembly, and a solution groups related projects.
  • Add projects to a solution with dotnet sln add and connect them with dotnet add reference.
  • Mark what other assemblies may use as public; keep implementation details internal.
  • dotnet add package records a PackageReference, and packages are restored at build time.
  • Ship with dotnet publish, choosing framework-dependent, self-contained, single-file, or native AOT output.

0 則留言

熱門留言由新到舊

登入 · 登入後即可留言。