冷やし C# 始めました

C# が話題だったので、改めて hello, world から入っていきます。

brew install dotnet-sdk

から入っていきます。

❯ dotnet new console -n HelloWorld


Welcome to .NET 9.0!
---------------------
SDK Version: 9.0.305

Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry

----------------
Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate, run 'dotnet dev-certs https --trust'
Learn about HTTPS: https://aka.ms/dotnet-https

----------------
Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
An issue was encountered verifying workloads. For more information, run "dotnet workload update".
The template "Console App" was created successfully.

Processing post-creation actions...
Restoring /Users/tokuhirom/tmp/20250919/HelloWorld/HelloWorld.csproj:
Restore succeeded.

ひな形が出来ました。

❯ tree HelloWorld/
HelloWorld/
├── HelloWorld.csproj
├── Program.cs
└── obj
    ├── HelloWorld.csproj.nuget.dgspec.json
    ├── HelloWorld.csproj.nuget.g.props
    ├── HelloWorld.csproj.nuget.g.targets
    ├── project.assets.json
    └── project.nuget.cache

2 directories, 7 files

Program.cs にはすでに hello, world が書かれていた。

// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
❯ ./bin/Release/net9.0/osx-arm64/HelloWorld
Hello, World!

やったー。これで僕も C# プログラマーだ!

❯ otool -L bin/Release/net9.0/osx-arm64/publish/HelloWorld
bin/Release/net9.0/osx-arm64/publish/HelloWorld:
	/System/Library/Frameworks/GSS.framework/Versions/A/GSS (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 2202.0.0)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 2202.0.0)
	/System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 61040.61.1)
	/System/Library/Frameworks/CryptoKit.framework/Versions/A/CryptoKit (compatibility version 1.0.0, current version 1.0.0)
	/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
	/usr/lib/swift/libswiftCore.dylib (compatibility version 1.0.0, current version 5.9.2)
	/usr/lib/swift/libswiftFoundation.dylib (compatibility version 1.0.0, current version 120.100.0)
	/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 1226.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1336.61.1)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1600.157.0)
	/usr/lib/swift/libswiftCoreFoundation.dylib (compatibility version 1.0.0, current version 120.100.0, weak)
	/usr/lib/swift/libswiftDarwin.dylib (compatibility version 1.0.0, current version 0.0.0, weak)
	/usr/lib/swift/libswiftDispatch.dylib (compatibility version 1.0.0, current version 34.0.2, weak)
	/usr/lib/swift/libswiftIOKit.dylib (compatibility version 1.0.0, current version 1.0.0, weak)
	/usr/lib/swift/libswiftObjectiveC.dylib (compatibility version 1.0.0, current version 8.0.0, weak)
	/usr/lib/swift/libswiftXPC.dylib (compatibility version 1.0.0, current version 29.0.2, weak)

Published: 2025-09-19(Fri) 17:47