CS0266: Cannot implicitly convert type 'double' to 'float'. An explicit conversion exists の原因と解決法
CS0266: Cannot implicitly convert type 'double' to 'float'. An explicit conversion exists の原因と具体的な解決手順をまとめました。
エラーメッセージ(全文)
CS0266: Cannot implicitly convert type 'double' to 'float'. An explicit conversion exists
このエラーとは
CS0266: Cannot implicitly convert type 'double' to 'float'. An explicit conversion exists は C# 開発でよく遭遇するエラーです。
想定環境: Windows / macOS / Linux
よく出る状況: C# / .NET / Unity 演習
よくある原因
- using 不足
- null 参照
- NuGet パッケージ
- ターゲットフレームワーク
解決方法
方法1: CS 番号で検索
Microsoft Docs の CSxxxx を確認.
それでも直らないとき
バージョン情報(C# のバージョン、OS、実行コマンド)を添えて、エラーメッセージ全文と直前に変更した点を確認してください。ログの数行上にも原因の手がかりが残っていることが多いです。
まとめ
「CS0266: Cannot implicitly convert type 'double' to 'float'. An explicit conversion exists」は using 不足 が原因のことが多いです。上記の手順で切り分けてください。
次にやること
同じ C# カテゴリの関連エラーもあわせて確認してください。
よくある質問
CS0266: Cannot implicitly convert type 'double' to 'float'. An explicit conve… とは何ですか?
CS0266: Cannot implicitly convert type 'double' to 'float'. An explicit conversion exists は C# 実行時に表示されるエラーです。using 不足
CS0266: Cannot implicitly convert type 'double' to 'float'. An explicit conve… の原因は?
using 不足。null 参照。NuGet パッケージ。
CS0266: Cannot implicitly convert type 'double' to 'float'. An explicit conve… の直し方は?
CS 番号で検索:Microsoft Docs の CSxxxx を確認.
C# で CS0266 が出るのはなぜ?
C# / .NET / Unity 演習
CS0266: Cannot implicitly convert type 'double' to 'float'. An explicit conve… を防ぐには?
。
次に読むべき記事
- CS0305: Using the generic type 'Dictionary<TKey, TValue>' requires 2 type arguments の原因と解決法
- CS0311: The type 'int' cannot be used as type parameter 'T' in the generic type or method 'Repository<T>' の原因と解決法
- CS0411: The type arguments for method 'Enumerable.Select<TSource, TResult>' cannot be inferred from the usage の原因と解決法
- Shader error in 'Standard': syntax error at line 42 の原因と解決法
- Assets/Scripts/Player.cs(12,9): error CS0103: The name 'transform' does not exist in the current context の原因と解決法
同カテゴリ「C#エラー」の記事
- Assets/Scripts/Player.cs(12,9): error CS0103: The name 'transform' does not exist in the current context の原因と解決法
- CS0029: Cannot implicitly convert type 'string' to 'int' in method Process491 の原因と解決法
- Microsoft.EntityFrameworkCore.DbUpdateException: duplicate key value violates unique constraint "IX_Users_Email_488" の原因と解決法
- CS8618: Non-nullable property 'Name483' must contain a non-null value when exiting constructor の原因と解決法
- CS0029: Cannot implicitly convert type 'string' to 'int' in method Process481 の原因と解決法
- Microsoft.EntityFrameworkCore.DbUpdateException: duplicate key value violates unique constraint "IX_Users_Email_478" の原因と解決法
人気記事
- TS2307: Cannot find module '@components/Widget601' or its corresponding type declarations の原因と解決法
- TS2307: Cannot find module '@components/Widget591' or its corresponding type declarations の原因と解決法
- TS2307: Cannot find module '@components/Widget581' or its corresponding type declarations の原因と解決法
- TS2307: Cannot find module '@components/Widget571' or its corresponding type declarations の原因と解決法
- TS2307: Cannot find module '@components/Widget561' or its corresponding type declarations の原因と解決法
- TS2307: Cannot find module '@components/Widget551' or its corresponding type declarations の原因と解決法
学習ルート
体系的に学びたい方はこちらから。
エラー・トラブル集で続きを探す →あわせて読みたい
- Shader error in 'Standard': syntax error at line 42 の原因と解決法同カテゴリの関連エラー
- Assets/Scripts/Player.cs(12,9): error CS0103: The name 'transform' does not exist in the current context の原因と解決法同カテゴリの関連エラー
- UnityException: Tag: Player is not defined の原因と解決法同カテゴリの関連エラー
- UnityEngine.MissingReferenceException: The object of type 'GameObject' has been destroyed の原因と解決法同カテゴリの関連エラー
- Unhandled exception. System.BadImageFormatException: Could not load file or assembly の原因と解決法同カテゴリの関連エラー