C# と VB.NET の質問掲示板

わんくま同盟

ASP.NET、C++/CLI、Java 何でもどうぞ

C# と VB.NET の入門サイト


(過去ログ 141 を表示中)
■82786 / )  次のメソットまたは、プロパティ間で呼び出しが不適切です
□投稿者/ ともや (1回)-(2017/02/04(Sat) 16:08:49)

分類:[C#] 

開発環境 Visual Studio Express2015 for Windows desktop
使用言語 C#
参考本 基礎からきちんと知りたい人のC#プログラミング入門(日経ソフトウエア 原田英生 著)

C#プログラミングをはじめて勉強しています。
参考本のステップ順にコードを記述していますが、
74~83行目のコードを記述すると、
70,97,100行目のLoadFileの下部に赤い波線が表示され、
赤い波線部にポインターを合わせると下記の内容が表示されます。

void Form1.loadFile(string value)
次のメソットまたは、プロパティ間で呼び出しが不適切です:
’Form1.LoadFile(string)'と'Form1.LoadFile(string)'

コードの記述に何か問題があるのでしょうか。
分かる方が居ましたら、教えていただけないでしょうか。


1     //テキストエディター(印刷機能付き)
2     
3     using System;
4     using System.Collections.Generic;
5     using System.ComponentModel;
6     using System.Data;
7     using System.Drawing;
8     using System.Linq;
9     using System.Text;
10    using System.Threading.Tasks;
11    using System.Windows.Forms;
12    
13    namespace MyMemo {
14      public partial class Form1 : Form {
15    
16        const string ApplicationName = "MyMemo";
17    
18        private string FileNameValue;
19        private string FileName {
20          get { return FileNameValue; }
21          set {
22            FileNameValue = value;
23            Edited = false;
24          }
25        }
26    
27        private bool EditedValue;
28        private bool Edited {
29          get { return EditedValue; }
30          set {
31            EditedValue = value;
32            UpdateStatus();
33          }
34        }
35    
36        private void UpdateStatus() {
37          string s = ApplicationName;
38          if (FileName != "")
39            s += " - " + FileName;
40          if (Edited) s += " (変更あり) ";
41          this.Text = s;
42    
43          if (FileName == "" || !Edited)
44            MenuItemFileSave.Enabled = false;
45          else
46            MenuItemFileSave.Enabled = true;
47    
48          if (!Enabled)
49            MenuItemFileSaveAs.Enabled = false;
50          else
51            MenuItemFileSaveAs.Enabled = true;
52        }
53    
54      public Form1() {
55          InitializeComponent();
56        }
57    
58        private void Form1_Load(
59          object sender, EventArgs e) {
60    
61           FileName = "";
62           textBoxMain.Multiline = true;
63           textBoxMain.ScrollBars = ScrollBars.Vertical;
64           textBoxMain.Dock = DockStyle.Fill;
65            saveFileDialog1.Filter = 
66               "テキスト文書|*.txt|すべてのファイル|*.*";
67    
68           if (1 < Environment.GetCommandLineArgs().Length) {
69             string[] args = Environment.GetCommandLineArgs();
70             LoadFile(args[1]);
71           }
72        }
73    
74            private void LoadFile(string value) {
75                if (System.IO.File.Exists(value)) {
76                    textBoxMain.Text = System.IO.File.ReadAllText(
77                      value, System.Text.Encoding.GetEncoding("Shift_JIS"));
78                    textBoxMain.Select(0, 0);
79                    FileName = value;
80                }
81                else
82                    MessageBox.Show(value + "が見付かりません", ApplicationName);
83            }
84    
85            private void MenuItemFileExit_Click(
86          object sender, EventArgs e) {
87    
88          this.Close();
89        }
90    
91        private void MenuItemFileOpen_Click(
92          object sender, EventArgs e) {
93    
94          openFileDialog1.FileName = "";
95          if (DialogResult.OK == 
96            openFileDialog1.ShowDialog())
97            LoadFile(openFileDialog1.FileName);
98        }
99    
100       private void LoadFile(string value) {
101         textBoxMain.Text = System.IO.File.ReadAllText(
102           value, System.Text.Encoding.GetEncoding(
103           "Shift_JIS"));
104   
105         FileName = value;
106       }
107   
108       private void MenuItemFileSaveAs_Click(
109         object sender, EventArgs e) {
110   
111         saveFileDialog1.FileName = System.IO.Path.GetFileName(FileName);
112   
113         if (DialogResult.OK == saveFileDialog1.ShowDialog())
114           SaveFile(saveFileDialog1.FileName);
115       }
116   
117       private void SaveFile(string value) {
118         System.IO.File.WriteAllText(value, textBoxMain.Text,
119           System.Text.Encoding.GetEncoding("Shift_JIS"));
120   
121         textBoxMain.Select(0, 0);
122   
123         FileName = value;
124       }
125   
126       private void MenuItemFileSave_Click(
127         object sender, EventArgs e) {
128   
129         SaveFile(FileName);
130       }
131   
132       private void textBoxMain_TextChanged(object sender, EventArgs e) {
133         Edited = true;
134       }
135     }
136   }

返信 編集キー/


管理者用

- Child Tree -