# C# の基礎 (.NET) > 変数と定数、プリミティブ型、control flow、クラス、struct、interface、例外 - 25 面接問題 - Junior - [面接問題: .NET](https://sharpskill.dev/ja/technologies/dotnet/interview-questions.md) ## 1. C# における変数とは何ですか? **回答** 変数とは、プログラムの実行中に変更できる値を保持する、メモリ上の名前付きの記憶領域です。各変数には型があり、その型によって保持できる値と許可される操作が決まります。明示的な型で変数を宣言すると、コンパイラがコードの整合性を検証し、メモリ使用を最適化できます。 ## 2. C# における変数と定数の違いは何ですか? **回答** 変数は初期化後に値を変更できますが、定数はコンパイル時に値を受け取り、プログラムの存続期間中ずっと固定されたままになります。定数は const キーワードで宣言され、コンパイル時に既知の値で初期化する必要があります。不変の値に定数を使うと可読性が向上し、コンパイラの最適化が可能になります。 ## 3. C# でシンプルな整数を格納するのに適した型は何ですか? **回答** int 型は、整数を格納するために C# で最もよく使われる整数型です。メモリ上で 32 ビットを占有し、約 -20 億から +20 億までの値を保持できます。カウンター、インデックス、数量を扱うほとんどのユースケースでは、int は値の範囲とパフォーマンスのバランスに優れています。 ## さらに22問利用可能 - C# で真偽値(true/false)を格納するにはどの型を使うべきですか? - C# で定数を宣言する正しい構文はどれですか? 無料で登録: https://sharpskill.dev/ja/login ## その他の.NET面接トピック - [LINQ & Delegates](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/csharp-linq-delegates.md): 20問, Junior - [C#言語の基礎](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/csharp-language-essentials.md): 15問, Junior - [ASP.NET Core の基礎](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/aspnet-core-fundamentals.md): 18問, Junior - [ASP.NET Core のリクエストライフサイクル](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/aspnet-core-request-lifecycle.md): 20問, Junior - [Configuration & Settings](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/configuration-settings.md): 20問, Junior - [アプリケーションのライフサイクル](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/application-lifecycle.md): 20問, Junior - [Dependency Injection](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/dependency-injection.md): 24問, Mid-Level - [Entity Framework Core](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/entity-framework-core.md): 25問, Mid-Level - [Minimal APIs](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/minimal-apis.md): 18問, Mid-Level - [Web API開発](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/web-api-development.md): 22問, Mid-Level - [ASP.NET Core における Async](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/async-aspnet-core.md): 20問, Mid-Level - [Authentication & Authorization](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/authentication-authorization.md): 18問, Mid-Level - [HttpClient & ネットワーキング](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/httpclient-networking.md): 20問, Mid-Level - [JSONシリアライズ](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/json-serialization.md): 20問, Mid-Level - [Entity Framework Core 応用](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/ef-core-advanced.md): 25問, Mid-Level - [C# の高度な機能](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/csharp-advanced-features.md): 20問, Mid-Level - [Clean Architecture](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/clean-architecture.md): 20問, Mid-Level - [Logging, Monitoring & Observability](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/logging-monitoring.md): 22問, Mid-Level - [ユニットテストとxUnit](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/unit-testing-xunit.md): 20問, Mid-Level - [統合テスト](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/integration-testing.md): 18問, Mid-Level - [Docker & Containerization](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/docker-containerization.md): 16問, Mid-Level - [NuGet パッケージ管理](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/nuget-package-management.md): 16問, Mid-Level - [Memory Management & GC](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/memory-management-gc.md): 22問, Senior - [リアクティブプログラミング](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/reactive-programming.md): 24問, Senior - [Async/await とパターン](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/async-await-patterns.md): 26問, Senior - [.NET デザインパターン](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/dotnet-design-patterns.md): 24問, Senior - [パフォーマンス最適化](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/performance-optimization.md): 22問, Senior - [セキュリティとベストプラクティス](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/security-best-practices.md): 24問, Senior - [SignalR とリアルタイム](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/signalr-realtime.md): 22問, Senior - [マイクロサービスアーキテクチャ](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/microservices-architecture.md): 25問, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/ja/technologies/dotnet/interview-questions/csharp-basics