Quantcast
Channel: C#タグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 8905

IDEなしでC#のHelloWorld

$
0
0

VisualStudioなどのIDEなしでC#のHelloWorldやってみます。

好きなところにソースコードを用意します。

ファイル名: helloworld.cs

usingSystem;publicstaticclassHelloWorld{publicstaticvoidMain(){Console.WriteLine("Hello C#!");}}

ソースコードをコンパイルしてexe形式にします。

C#の環境を確認

.NET Frameworkがインストールされていれば以下の場所にバージョンごとの.NET Frameworkが存在します。

32bit Windowsの場合
%windir%\Microsoft.NET\Framework

64bit Windowsの場合
%windir%\Microsoft.NET\Framework64

こんな感じ
image.png

バージョンのディレクトリの配下にcsc.exeというコンパイラが存在します。
image.png

コンパイルしてみる

> C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe helloworld.cs
Microsoft (R) Visual C# Compiler version 4.8.3752.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.

This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest version. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240

image.png

コンパイルエラーはこんな感じに出ます。

helloworld.cs(6,35): error CS1002: ; が必要です。

exe実行してみる

> .\helloworld.exe
Hello C#!

Viewing all articles
Browse latest Browse all 8905

Trending Articles